203 Star 1.3K Fork 342

ele-admin / treetable-lay

 / 详情

2.x pid问题 子级在父级下 但是子级还会以父级出现在列表

Done
Opened this issue  
2019-12-03 14:43

输入图片说明

 var data = [{
					id: '1',
					pid: '0',
					name: 'xxx',
					createTime: '2019/11/18 10:44:00',
				}, {
					pid: '1',
					id: '1_1',
					name: 'xxx',
					createTime: '2019/11/18 10:44:00'
				},{
					id: '2',
					pid: '0',
					name: 'xxx',
					createTime: '2019/11/18 10:44:00',
				},{
					pid: '2',
					id: '2_1',
					name: 'xxx',
					state: 0,
					createTime: '2019/11/18 10:44:00',
				   
				}];
        // 渲染表格
        var insTb = treeTable.render({
            elem: '#demoTreeTable1',
            data: data,  // 数据
			tree: {
				
				iconIndex: 1,  // 折叠图标显示在第几列
				isPidData: true  // 是否是pid形式数据
			},
			cols: [
				{type: 'numbers'},
				{field: 'id', title: 'ID'},
				{field: 'name', title: 'name', width: 160},
				{field: 'createTime', title: '创建时间', width: 180}
			],
            style: 'margin-top:0;'
        });

Comments (1)

renbo created任务
renbo changed description
Expand operation logs
 // 渲染数据
        if (options.reqData) {  // 异步加载
            this.renderBodyAsync();
        } else {  // 一次性渲染
            if (options.data && options.data.length > 0) {
                // 处理数据
                if (options.tree.isPidData) {  // pid形式数据
                    //将转成childen的数据重新赋值给options.data解决
                    options.data = treeTb.pidToChildren(options.data, options.tree.idName, options.tree.pidName, options.tree.childName);
                } else {  // children形式数据
                    addPidField(options.data, options.tree);
                }
                $table.children('tbody').html(this.renderBody(options.data));
                $tbLoading.hide();
                this.renderNumberCol();  // 渲染序号列
                form.render(null, tbFilter);  // 渲染表单元素
                this.checkChooseAllCB();  // 联动全选框
                updateFixedTbHead($view);
            } else {
                $tbLoading.hide();
                $tbEmpty.show();
            }
        }     
ele-admin changed issue state from 待办的 to 已完成

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(1)
JavaScript
1
https://gitee.com/ele-admin/treetable-lay.git
git@gitee.com:ele-admin/treetable-lay.git
ele-admin
treetable-lay
treetable-lay

Search