EasyUI treegrid collapseAll最初

时间:2016-03-14 17:11:19

标签: javascript jquery asp.net jquery-easyui

我使用下面的示例来填充层次结构。

http://www.jeasyui.com/documentation/treegrid.php

最初加载时,树全部展开。是否有任何设置我错过加载树最初都崩溃了。我在数据选项中尝试过“state:'closed'但它无效。

1 个答案:

答案 0 :(得分:0)

如果您使用"转换"过滤器,您可以将状态属性添加到您的节点

while(toDo.length){
    var node = toDo.shift();    // the parent node
    // get the children nodes
    for(var i=0; i<rows.length; i++){
        var row = rows[i];
        if (row.parentId == node.id){
            var child = {id:row.id,text:row.name, state:'closed'};
            if (node.children){
                node.children.push(child);
            } else {
                node.children = [child];
            }
            toDo.push(child);
        }
    }
}