I am using a jqgrid’s treegrid and the data for the child nodes is being loaded on request.
But when user clicks on a node (say node1) to expand it and immediately clicks on another node (say node2) then the children of first node (node1) are being displayed for the second node (node2), the icon of node2 changes to show as expanded but it has data of node1’s children and collapsing node2 doesn’t do anything but collapsing node1 collapses node1’s children which are displayed as node2’s children.
Did someone else face such a problem? data for jqgrid is adjacency model in json format.
It looks like a bug in jqGrid. I looked in the code and I think I understand the problem.
Every time the user click on the “expand” icon the code will be executed which call
expandRowandexpandNodemethods. The code ofexpandNodefirst overwrite the current value of thetreeANodeparameter of jqGrid which are used internally to identify the row after which the new data will be added. Then thenodeid,parentid(orn_leftandn_rightfor the'nested'grid model) andn_levelparameters of the new request to the server will be set and after that thereloadGridwill be triggered.The problem is that later, during processing of the
reloadGridat the beginning of the internalpopulatemethod, the internal.grid.hDiv.loadingproperty will be tested and if it was set be the previous still pending request then the second reloading of the grid will be skipped. The problem is that the value of thetreeANodeparameter is already changed. So the items returned as the children of the first expending node will be added as clidren of the last clicked node.As the bug fix I suggest to modify the line of code to the following
In the way the
treeANodeparameter will be not overwritten by the click on the second if another pending request is still processing.You can download from here the modified version of the
jquery.jqGrid.src.jsand test whether the problem will be solved after the bug fix. If it will solve the problem I’ll post the corresponding bug report with my suggestion how to fix the problem on the trirand forum.As another workaround you can use
loadui: 'block'option of jqGrid which will not allow any user interactions during the processing of the pending requests to the server.