var requestUrl = "/Request/Fork.ashx?action=Check"&temp=" + new Date(); grid = $("#maingrid").ligerGrid({ height: '100%', columns: [ { display: 'parent_id', name: 'parent_id', width: 110 , hide: true }, { display: 'SKU', name: 'User_code', width: 150 }, ], pageSize: 10 , width: '99.9%', columnWidth: 100, isScroll: true, frozen: true, pageSizeOptions: [10,20, 40, 50, 100], url: requestUrl, showTitle: false, rownumbers: false, // alternatingRow: false, tree: { columnName: 'User_code' }, //以樹形顯示的字段id ,或者name值也可以 onAfterShowData: function() { //var l = $(".l-grid-tree-link-open").length; //for (var i = l - 1; i >= 0; i--) // $(".l-grid-tree-link-open")[i].click(); collapseAll(); }, checkbox: false, isScroll: true, autoCheckChildren: false, onError: function (a, b) { alert("錯誤的請求"); } });
在使用 ligerui的 表格 Tree中 首次加載沒問題,查詢後顯示
Uncaught TypeError: p.tree.isParent is not a function
at $.ligerui.controls.Grid._getTreeCellHtml (VM10446 ligerui.all.js:12085)
定位到JS中可見 p.tree.isParent,
通過 log 發現 JSON.stringify(p.tree) 具體內容,發現需要在 tree: { columnName: 'User_code' ,isExtend:true,"childrenName":"children",},
然後JS 修改:
if (p.tree.isParent == undefined) {
p.tree.isParent = function (rowData) {
var exist = p.tree.childrenName in rowData;
return exist;
}
}
var isParent = (p.tree.isParent == undefined ?
function (rowData) {
var exist = p.tree.childrenName in rowData;
return exist;
}
: p.tree.isParent(rowdata)); //原始