Forum
09:50
07/04/2009
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>
04:22
Moderators
30/10/2007
Hello,
Will try to add this missing feature.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
07:45
16/04/2009
09:20
16/04/2009
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
Moderators
30/10/2007
Hello,
Thanks Craig. Definitley will do that.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
21:18
11/05/2009
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?
22:11
27/02/2010
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
Moderators
30/10/2007
Hello,
Thenks. I will try it.
Best Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
01:26
27/05/2010
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!
Most Users Ever Online: 715
Currently Online:
29 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66