| User | Post |
|
09:50 12/04/2009
| idosius
| | | |
| Member | posts 6 |
|
|
Hi all,
jqGrid is a marvelous plugin and it has been working well for me up to now. Unfortunately, I seem to have hit a brick wall. I would really appreciate your help to get around it.
I've been trying to get a treegrid to work with client side data by adding it with setTreeRow, but to no avail. All I get is the table header and absolutely no data in it.
Please see my code below. Any help would be greatly appreciated.
Thanks in advance,
Ido
<html> <head> <link type="text/css" href="css/custom-theme/ui.all.css" rel="stylesheet" /> <link rel="stylesheet" type="text/css" media="screen" href="themes/basic/grid.css" />
</head> <body> <script src="jquery/jquery-1.3.2.js"></script> <script src="jquery/grid.locale-en.js"></script> <script src="jquery/grid.base.js"></script> <script src="jquery/grid.subgrid.js"></script> <script src="jquery/grid.treegrid.js"></script>
<table id="list" class="scroll"></table> <script> jQuery(document).ready(function(){ jQuery("#list").jqGrid({ datatype: 'clientSide', treeGrid: true, treeGridModel : 'adjacency', ExpandColumn : 'invid', colNames:['Inv No','Amount'], colModel :[ {name:'invid',index:'invid', width:55, sorttype:'int'}, {name:'amount',index:'amount', width:80, align:'right',sorttype:'float'}, ], imgpath: 'themes/basic/images', height:'auto' }); // populate the table with some values for (var i=0; i<50; i++) { jQuery("#list").setTreeRow(i, { invid: i, amount: "300.00″, level: 0, parent: null, isLeaf: true, expanded: false }); } }); </script> </body> </html>
|
|
|
02:56 13/04/2009
| idosius
| | | |
| Member | posts 6 |
|
|
OK, I realized I made a mistake – one cannot use setTreeRow before doing addRowData. However, when I do add data with addRowData I don't get a tree structure but a flat table. Anyone know why?
Thanks,
Ido
|
|
|
07:29 13/04/2009
| idosius
| | | |
| Member | posts 6 |
|
|
After doing some digging and conversing with myself also outside this forum , may I ask if treegrids are supported for client side data at all?
|
|
|
04:22 14/04/2009
| tony
| | Sofia, Bulgaria | |
| Moderator
| posts 6995 |
|
|
Hello,
Will try to add this missing feature.
Regards
Tony
|
|
|
04:41 14/04/2009
| idosius
| | | |
| Member | posts 6 |
|
|
Thanks! In the meanwhile this should also be written in the documentation, unless it's there already.
Best Regards,
Ido
|
|
|
07:45 17/04/2009
| Craig Stuntz
| | Columbus, OH, USA | |
| Member | posts 16 |
|
|
This is working correctly for me. I am using a tree grid and populating it with data on the client side. I'm using the adjacency model. Which part is not working for you?
|
|
|
03:11 19/04/2009
| idosius
| | | |
| Member | posts 6 |
|
|
I tried using both adjacency and nested models and it didn't work. Would you mind sharing your code? It could really help me out.
Thanks,
Ido
|
|
|
09:20 20/04/2009
| Craig Stuntz
| | Columbus, OH, USA | |
| Member | posts 16 |
|
|
Would you mind sharing your code? It could really help me out.
Here, I made you a demo:
$(document).ready(function() { TreeDemo.setupGrid($("#tree")); });
TreeDemo = { data: { A: ["A1", "A2"], B: ["B1", "B2"] }, setupGrid: function(grid) { grid.jqGrid({ colNames: ['Name'], colModel: [ { name: 'Name', index: 'Name', width: "250em" } ], datatype: TreeDemo.treeData, loadui: "none", sortname: 'Number', treeGrid: true, treeGridModel: "adjacency", sortorder: "asc" }) }, treeData: function(postdata) { var items = postdata.nodeid ? TreeDemo.data[postdata.nodeid] : TreeDemo.data; var i = 0; var rows = new Array(); for (val in items) { var isLeaf = postdata.nodeid != undefined; rows[i] = { Name: val, Id: val, level: postdata.nodeid ? 1 : 0, parent: postdata.nodeid || null, isLeaf: isLeaf ? "true" : "false", expanded: "false" } i++; } $("#tree")[0].addJSONData({ Total: 1, Page: 1, Records: 2, Rows: rows }); } };
Please feel free to add this to the tree documentation.
|
|
|
07:49 22/04/2009
| tony
| | Sofia, Bulgaria | |
| Moderator
| posts 6995 |
|
|
Hello,
Thanks Craig. Definitley will do that.
Best Regards
Tony
|
|
|
21:18 10/05/2009
| J_jack_K
| | | |
| Member | posts 3 |
|
|
Hi,
I've used the same Craig solution and all work fine.
I have only a problem: if I open the node the tree grid add correclty the new rows but when I colse it they don't disappare.
When I open the node again it's load again the row and duplicate them.
Here a piece of my code:
jQuery('#amm_organizations_grid').jqGrid({ treeGrid: true, height:'auto', treedatatype: 'json', treeModel : 'adjacency', ExpandColClick : false, datatype: function(postdata) { var gridJson=jsonToTree(postdata,ecx_global['JsonOrganizzazioni']); var thegrid = jQuery("#amm_organizations_grid")[0]; thegrid.addJSONData(gridJson); }, colNames: ['Organizzazione','Utenti'], colModel: [ {name:'code', index:'code', width:200, sortable:false}, {name:'usersNumber', index:'usersNumber', width:70, sortable:false}], jsonReader: { root: "rows", id: "id", page: "page", total: "total", records: "records", repeatitems: false }, pager: jQuery('#amm_organizations_grid_pager'), viewrecords: true, imgpath: '/ECXMSResources/jquery-plugins/jqGrid/themes/steel/images' });
Json returned from jsonToTree the first time:
{"total":1,"page":1,"rows":[ {"code":"root","id":"1","usersNumber":"","level":0, "parent":"NULL","isLeaf":"false","expanded":"false"}], "records":1}
Json returned from jsonToTree the opening the first node (id=1):
{"total":1,"page":1,"rows":[ {"code":"org_1.0.0","id":"333","usersNumber":"","level":1, "parent":"1","isLeaf":"false","expanded":"false"}, {"code":"org_1.1.1","id":"334","usersNumber":"","level":1, "parent":"1","isLeaf":"false","expanded":"false"} ],"records":2}
Some Ideas?
|
|
|
21:33 10/05/2009
| J_jack_K
| | | |
| Member | posts 3 |
|
|
P.S. I'm using the Stable 3.4.3 Version
|
|
|
22:17 10/05/2009
| J_jack_K
| | | |
| Member | posts 3 |
|
|
SOLVED:
I've used treeModel to set the adjacency mode (as wrote in Treegrids decumentation).
Using treeGridModel instead all work fine.
|
|
|
22:11 27/02/2010
| MattyCiii
| | | |
| Member | posts 4 |
|
|
Try as I might, I simply cannot get this ( the Craig Stuntz example) to work with jqGrid 3.6.4.
I know I have the basics of jqGrid working correctly (all the dependancies, etc), because I have a separate example working fine (a jqGrid built from JSON).
Possibly related, it seems the jqGrid demos "New in version 3.4 –> Tree Grid Adjacency Model " demo does not work, at least in MacOS Safari 4.0.4, MacOS FireFox 3.6, and Win 7 FireFox 3.6.
Any thoughts?
~Matt
|
|
|
17:32 31/03/2010
| tony
| | Sofia, Bulgaria | |
| Moderator
| posts 6995 |
|
|
Hello,
Thenks. I will try it.
Best Regards
Tony
|
|
|
01:26 27/05/2010
| acornel
| | | |
| Member | posts 9 |
|
|
I have the same problem: the Craig Stuntz example does not work (even it is a straightforward example). I have tested it on version 3.6.4 and 3.6.5 and on IE / FF … and no chance (nothing displayed).
The demo examples on the website are working fine … so maybe it is a problem related to addJSONData (same asa addRowData)?
Thank you in advance for your answer!
|
|