1

I have my data stored in database in flat structure with out any heirarchical fashion and currently displaying in tabular format using jqgrid. I would like to display it in drill down fashion like the count at the top levels, child levels like this in nested fashion. Is it possible to do using jqgrid...

varaprakash
  • 487
  • 4
  • 12
  • 30

1 Answers1

1

I think that the best way to make some queries used GROUP BY on the server side to construct the information about the hierarchy of the data. In the way you will be construct the tree structures which you need. The main data will get isLeaf:true, level:4, expanded:false, loaded:true properties and parent property with the id of the parent node "2200". If you would use as ids the values with prefixes like 'e' for 'Event', 'm' for 'Model' and so on you will be easy construct unique ids for every row so you will be able to construct all data for the Tree Grid on the server and then place the data in the server response.

Alternatively you can fill only the top level of the tree grid. You can construct simply query which will produce the resulting set. If the user will opens some tree node the new request will be sent to the server. The request will contains the some additional parameters: nodeid, parentid and n_level. If you good choose the id values of on the root items you will have full information to construct query which will get you the next level on the tree. You should use parentid as to construct the WHERE part of the query. In the way you can also construct the tree and load all noded on-demand.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks Oleg. I have already implemented it using similar approach and if you look at my question [here](http://stackoverflow.com/questions/9446992/jqgrid-tree-grid-displaying-radio-off-icon-for-last-child-node), it has that tree structure that I implemented yesterday. Thanks for the suggestions. I was using load on demand technique and also working on loading the data up front... – varaprakash Feb 25 '12 at 21:09
  • @varaprakash: OK! It the future it would be good if you either write your own answer on your question and mark it later as "accepted". You can also modified the question and include the word SOLVED in the title or just delete the question. The best would be to share your solution with other people. – Oleg Feb 25 '12 at 21:14
  • Sure Oleg, I got that idea after posting the question and also wanted to see your ideas/suggestions on the implemention. Any how I had to wait for atleast a day to accept my own question so could n't do it y'day. Thanks again and you are always helpful! – varaprakash Feb 25 '12 at 21:18