$("#mainGrid").treegrid({
fit: true,
toolbar: "#toolbar",
fitColumns: false,
width: $(window).width() - 22,
height: $(window).height() - 110,
rownumbers: false,
pagination: false,
striped: true,
idField: "id",
treeField: "name",
columns: [
[
{
field: "name",
title: "部門名稱",
halign: "center",
align: "left",
width: 350
},
{
field: "createName",
title: "創建人",
halign: "center",
align: "center",
width: 300
}
]
],
loader: function(param, success, error) {
ajax.getList(param, success);
},
// 在 onLoadSuccess函數中設置,遍歷所有根節點調用collapseAll. onLoadSuccess: function(row, data) { $.each(data, function(i, val) { $("#mainGrid").treegrid("collapseAll", data[i].id); }); }
});