可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题: 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
$ ( '
').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" } ] } ] };
跳转到