1

I'm using a tree grid with local data. And I'm interesting in best practices that can improve performance and design of my grid. So I found a related post and would like to know in what case it can be useful to pass undeclared property "loaded:true" as a data source. I'd appreciate your answers (especially @Oleg answer :)).

Community
  • 1
  • 1
amigo
  • 343
  • 5
  • 19

1 Answers1

1

TreeGrid was implemented originally so that it holds all additional information about the tree structure in hidden columns of jqGrid. Later jqGrid starts to supports local data, but the hidden columns still exists in every row.

Old versions of TreeGrid can load only the data from the server. At the beginning jqGrid needs to load only the root nodes (the nodes which parent is null). If the node need be expanded then new Ajax request with additional parameters nodeid, parentid and n_level (or nodeid, n_left, n_right, n_level in case of usage treeGridModel: "nested") will be sent to url. The server should returns the data based on the parameters. Once the data will be loaded and the node need be collapsed the children will be make just hidden using display: none CSS style. Next time jqGrid should don't load the data from the server once more. Instead of that jqGrid just show children of the node. Exactly in the case the loaded column (the hidden column) of the parent node will hold true value.

In case of creating TreeGrid with local data all works exactly like described above. It's a pity, but TreeGrid don't support datatype: "local" till now, but one can do almost the same by usage datatype: "jsonstring". My old answer which you referenced in your question demonstrates the approach. Because the structure of jqGrid (TreeGrid) is still oriented of remote loading one should just set loaded:true property on all nodes of the data. As the result the remote TreeGrid works without any additional communication with the server. All the data will be loaded at once, but collapsed node fill follows hidden children.

So one can say, that the usage of loaded:true property is a hack which allows to load all TreeGrid data at once and to make late expanding or collapsing of nodes without any additional communication with the server.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798