I am testing trees in jqgrid, so far I am only able to create something like below
I want to have something like jqGrid Demo page
I came up with the below code, but no idea how should I go about expanding each row in the tree from the given json format
$('<table id="list2" cellspacing="0" cellpadding="0"></table></div>').appendTo('#topics');
var grid = jQuery("#list2");
grid.jqGrid({
datastr:topicjson,
datatype: "jsonstring",
height: "auto",
pager: false,
loadui: "disable",
colNames: ["id","Items","url"],
colModel: [
{name: "id",width:1,hidden:true, key:true},
{name: "elementName", width:150, resizable: false},
{name: "url",width:1,hidden:true}
],
treeGrid: true,
caption: "jqGrid Demos",
ExpandColumn: "elementName",
autowidth: true,
//width: 180,
rowNum: 200,
//ExpandColClick: true,
treeIcons: {leaf:'ui-icon-document-b'},
jsonReader: {
repeatitems: false,
root: "response"
}
});
Json format
var topicjson={
"response": [
{
"id": "1",
"elementName": "Grouping",
"sub": [
{
"subelementName": "Simple Grouping"
},
{
"subelementName": "May be some other grouping"
}
]
},
{
"id": "2",
"elementName": "CustomFormater",
"sub": [
{
"subelementName": "Image Formatter"
},
{
"subelementName": "Anchor Formatter"
}
]
}
]
};