EasyUI treegrid设置折叠节点(默认展开一级节点)
$("#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); }); } });