$(function() {
$("#jqGrid").jqGrid({
url: baseURL + 'sys/datadictionary/list',
datatype: "json",
//treeGrid: true,
//treeGridModel: 'adjacency',
ExpandColumn: 'parentName',
colNames: ['dictId', '类别', '上一级字典', '代码', '值', '状态'],
colModel: [{
label: "字典id",
name: "dictId",
index: "dictId",
field: "dict_id",
key: true,
hidden: true
},
{
label: '类别',
name: 'name',
field: "name",
index: 'name',
width: 75
},
{
label: '上一级字典',
name: 'parentName',
index: 'parentName',
field: "parentName",
width: 75
},
{
label: '代码',
name: 'dictCode',
field: 'dictCode',
index: 'dict_code',
width: 100
},
{
label: '值',
name: 'dictValue',
index: 'dict_value',
field: 'dictValue',
width: 80
},
{
label: '状态',
name: 'status',
index: 'status',
width: 80,
formatter: function(value, options, row) {
return value === 0 ? '<span class="label label-danger">禁用</span>': '<span class="label label-success">正常</span>';
}
}],
viewrecords: true,
height: "100%",
rowNum: 10,
rowList: [10, 30, 50],
rownumbers: true,
rownumWidth: 25,
autowidth: true,
multiselect: true,
pager: "#jqGridPager",
jsonReader: {
root: "page.list",
page: "page.currPage",
total: "page.totalPage",
records: "page.totalCount"
},
// treeReader: {
// level_field: "level",
// parent_id_field: "parent",
// leaf_field: "isLeaf",
// expanded_field: "expanded"
// },
prmNames: {
page: "page",
rows: "limit",
order: "order"
},
gridComplete: function() {
//隐藏grid底部滚动条
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({
"overflow-x": "hidden"
});
// var table = new TreeTable(jqGrid, baseURL + "sys/datadictionary/list1", colModel);
// table.setRootCodeValue(r.dictionaryId);
// table.setExpandColumn(2);
// table.setIdField("dictId");
// table.setCodeField("dictId");
// table.setParentCodeField("parentId");
// table.setExpandAll(false);
// table.init();
// jqGrid = table;
}
});
});
把注释放开还是不能显示树形结构
[code=javascript]
[/code]