Ng Alain 工具集-ArrayService

ArrayService

arrToTreeNode

将含有层级关系的数组转换成 `nz-tree` 数据源

//源数据处理为NzTreeNode类型
    treeDataMap(data): NzTreeNode[] {
        return this.arrayService.arrToTreeNode(data, {
            idMapName: 'key',
            titleMapName: 'title',
            parentIdMapName: 'parentId',
            isLeafMapName: 'isLeaf'
            , cb: item => {
                item.checked = false;
            }
        });
    }

data的源数据结构

        public string Key { get; set; }
        public long Value { get; set; }
        public string Title { get; set; }
        public string ParentId { get; set; }
        public bool IsLeaf = false;
        public bool Selectable { get; set; }

 

posted @ 2023-06-16 15:11  流年sugar  阅读(4)  评论(0编辑  收藏  举报