0

I want to load child nodes on expansion. In the documentation, they mentioned that the request having level, isexpanded, etc. values will be sent to server, when click on expansion icon. But for me no url is being sent to server when i expand any node. What setup i have to do to make it work.

My existing setup is as below :-

jQuery("#tree").jqGrid({
url:'getTasks.htm',
datatype: "json",
mtype:'GET',
colNames: ["id", "no.", "name"],
colModel: [
    {name:'id',width: 30, editable:false, align:"right",sortable:false, hidden: true, key: true},
    {name:'no',width:80, editable:false, align:"left", sortable:true, sorttype:"int"},
    {name:'name', width:150, editable:true, sortable:true, sorttype:"text"}

],

treeGridModel:'adjacency',
treeGrid: true,
gridview:true,
treedatatype: 'json',
cellEdit: true,
ExpandColumn:'name',
cellsubmit : 'clientArray',

jsonReader : {
    root:"listTasks",
    cell:"",
    id: "id",
    repeatitems:false

}

Sample JSON data is :-

[Object { id="16731", no="1", name="name1", level="0", parent="null", isLeaf="false", expanded="false", loaded="true", icon="ui-icon-triangle-1-s"}, Object { id="16737", no="2", name="name2", level="0", parent="null", isLeaf="false", expanded="false", loaded="true", icon="ui-icon-triangle-1-s"}, Object { id="18846", no="3", name="name3", level="0", parent="null", isLeaf="false", expanded="false", loaded="true", icon="ui-icon-triangle-1-s"}, Object { id="-1", no="(new)", parent="null",level="0", isLeaf="false", expanded="false", loaded="true", icon="ui-icon-triangle-1-s"}]
Rondel
  • 4,811
  • 11
  • 41
  • 67
mayur
  • 47
  • 1
  • 3
  • 11

1 Answers1

1

You can find in the documentation of TreeGrid (see here) that the tree parameters: nodeid, parentid, n_level will be sent to the server on expanding of an node in case of treeGridModel:'adjacency'. No "url" should be send.

It is additionally important which value have the value for the loaded hidden column. If you fill all the data in the TreeGrid at the first load you should place true in the column, no request to the server will be send on the node expanding.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Oleg : Was waiting for your reply..!! I have checked the link you provided. It means for load child on expansion, i have to use postdata option of jqgrid. In the example, postdata is having rc.id,rc.n_level,etc. How do i get rc(expanded row id). Do i need to trigger click event on click on the icon ?? – mayur Mar 15 '12 at 09:53
  • @mayur: You don't need to use `postData` option. The parameters `nodeid`, `parentid`, `n_level` will be added *automatically* by jqGrid. You should just implement in the code on the server side the test whether `nodeid`, `parentid`, `n_level` parameters are send. If there are not send the server should return top-level nodes. If the three parameters do defined you have to send back *only the children* of the node `nodeid`. No other trigger on clicks are need be implemented. – Oleg Mar 15 '12 at 09:59
  • Can you give any example for that?? – mayur Mar 15 '12 at 10:18
  • @mayur: You need code *on the server side*. What language and technology you use? – Oleg Mar 15 '12 at 10:21
  • @mayur: I don't use Java and don't use `spring`, but the first page which I find on searching for "jqGrid" AND "spring" ([the page](http://krams915.blogspot.com/2010/12/jqgrid-and-spring-3-mvc-integration.html)) it seems that one should just use prefixes like `@RequestParam("nodeid")` for the server method called by `'getTasks.htm'`. in the case you will get the values of all parameters which jqGrid send. – Oleg Mar 15 '12 at 10:30
  • I checked out the example and also tried to do it accordingly. But the problem is, only 6 parameters are sent to server every time. and on click expansion, no request is made .. The params sent to server on first load are : - _search false, nd 1331813263967, page 1, rows 10000, sidx, sord asc, – mayur Mar 15 '12 at 12:09
  • @mayur: Which values you set for the hidden `loaded` column? Could you append your question with the test JSON data? – Oleg Mar 15 '12 at 12:23
  • i am setting true value only. And also, first time i am passing only rows that are most parent. I have updated the question also with sample json data. – mayur Mar 15 '12 at 12:36
  • @mayur: You have to use `loaded: false` for the node to be able to load children of the node on expanding. – Oleg Mar 15 '12 at 14:26
  • Thank you very much... !! Its working Correctly.. But still i am getting the performance hit.. when there are more than 50 child tasks to load.. its giving stop script error.. I went through all these questions to improve treegrid performance... [this](http://stackoverflow.com/questions/9574708/jqgrid-treegrid-performance-issues-in-ie8/9575200#9575200) and [this](http://stackoverflow.com/questions/6275903/improving-jqgrid-tree-grid-performance).. and also made appropriate changes.. Still getting that stop script error for 50 child tasks... – mayur Mar 19 '12 at 09:20
  • the exact error is this .... Script: http://...../common/js/jquery-1.5.2.js:4687 – mayur Mar 19 '12 at 09:55
  • @mayur: if you have performance problems with only 5 children and you made correctly the fix described [here](http://stackoverflow.com/questions/9574708/jqgrid-treegrid-performance-issues-in-ie8/9575200#9575200) I recommend you to open new question and post mostly full information which can be used to reproduce the problem. Full test JSON data for the first grid loading and the loading of children is required. You can use [Fiddler](http://www.fiddler2.com/fiddler2/) or Firebug to catch pure JSON response from the server. The data in form `[Object { id="16731", no="1" ...` can't be used. – Oleg Mar 19 '12 at 10:07
  • Thanks for the help... I think its because of my system slowness.. though i will test it again.. and if still problem comes will open it as a new question.. Thanks again.. !! – mayur Mar 19 '12 at 10:45
  • @mayur: You are welcome! I think that the grid with 50 child have to work quickly even on the very slow system. So I more suppose that it's either one more bug in jqGrid or that you use jqGrid not in the best way. In both cases one need first be able to reproduce the problem and then can one fix it. – Oleg Mar 19 '12 at 11:01
  • you are right.. !! I will revisit my code.. and will remove all unwanted statements .. About the JSON response from server.. Spring MVC itself converts my json data in this format... I am not doing it explicitly... The link i reffered for that is [here](http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/).. !! – mayur Mar 19 '12 at 11:16
  • @mayur: I don't use Spring myself. The description of the implementation can also not really have to find the bug. So I need be able *to reproduce* the problem and *to debug* it. If you can provide the live link where non-minimized version of jqGrid `jquery.jqGrid.src.js` will be used I could debug the page and find the reason. Alternatively you can use [Fiddler](http://www.fiddler2.com/fiddler2/) or [Firebug](http://getfirebug.com/) to catch real HTTP traffic and I could reproduce the problem without your server. Fiddler even allows to define autoresponder to simulate the server. – Oleg Mar 19 '12 at 11:28
  • In firefox browser -> about:config , i changed the dom.system.runtime to some bigger value and than, at least for 50 tasks, its not showing any problem (no error) .... – mayur Mar 20 '12 at 09:57
  • need help on [this](http://stackoverflow.com/questions/9357307/while-editing-any-field-of-expand-column-of-treegrid-in-jqgrid-getting-html-co) issue... !! – mayur Apr 02 '12 at 12:22