Forum
23:38
30/06/2011
Trying to us the jqgrid as a tree, prefer to add nodes manually, something like the code below. I have tried using the addChildNode method with no luck. I know the docs say 'Currently jqGrid can work only with data returned from server.', but the 4.0.0 changes "Added method addChildNode". I am using custom async (jQuery ajax) calls to retrieve data from the server, upon callback I would like to just add the appropriate nodes to the tree. Also the parameters to addChildNode are defined as: nodeid, parentid, data, but the data parameter also contains nodeid, parentid - ?
$("#tree1").jqGrid({
datatype: function (treePostData) { treeLoad(treePostData); },
colNames: ["id", "name"],
colModel: [
{ name: 'id', index: 'id', width: 1, hidden: true, key: true },
{ name: 'name', index: 'name', width: 180 }
],
height: '100%',
rowNum: 10000,
sortname: 'id',
treeGrid: true,
treeGridModel: 'adjacency',
treedatatype: function (treePostData) { treeLoad(treePostData); },
ExpandColumn: 'name',
caption: "Tree Grid"
});
function treeLoad(treePostData){
//add nodes to the grid
//not working... nodeid, parentid, data
//the following line throws a javascript error in jquery-1.6.1, line 998: 'undefined' is null or not an object
$("#tree1").jqGrid("addChildNode", "1", null, { id: "1", name: "xyz1", level: 0, parent: null, isLeaf: false, expanded:false });
}
Most Users Ever Online: 715
Currently Online:
40 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