设置easyui treegrid 默认折叠节点

在 onLoadSuccess函数中设置,遍历所有根节点调用collapseAll.
示例:

$('#myTask').treegrid({
        width:    _w - sidebarWidth,  
        height:    _h - 90, 
        url:'/ProjectManSys/indexTask/',  
        //method:'get',
        idField:'id',
        treeField:'name',
        //toolbar: '#projectTb',
        autoRowHeight: true,
        striped:true,
        fitColumns: true,
        //scrollbarSize: 400,
        animate:false,
        rownumbers:false,
        columns:[[
            {title:'id',field:'id',hidden:true},
            {field:'name',title:'名称',width:($(window).width() - sidebarWidth) * 0.1,formatter:onFormatterTask}, 
            {field:'user',title:'人员',width:($(window).width() - sidebarWidth) * 0.1},
            {field:'status',title:'状态',width:($(window).width() - sidebarWidth) * 0.1}, 
            {field:'startTime',title:'开始时间',width:($(window).width() - sidebarWidth) * 0.1},
            {field:'endTime',title:'结束时间',width:($(window).width() - sidebarWidth) * 0.1},
            {field:'desc',title:'描述',width:($(window).width() - sidebarWidth) * 0.1}
        ]],
        rowStyler:onTaskRowStyle,
        onLoadSuccess: function (row, data)
        {
            $.each(data, function (i, val) { $('#myTask').treegrid('collapseAll', data[i].id)})
        }
    });

 

posted on 2014-01-17 17:41  V42  阅读(6950)  评论(0编辑  收藏  举报