Пример #1
0
 /// <summary>
 /// 是否叶节点
 /// </summary>
 protected virtual bool IsLeaf(ZorroTreeNode node)
 {
     if (node.Key.IsEmpty())
     {
         return(true);
     }
     return(_data.All(t => t.ParentId != node.Key));
 }
Пример #2
0
 /// <summary>
 /// 初始化叶节点状态
 /// </summary>
 protected virtual void InitIsLeaf(ZorroTreeNode node)
 {
     node.IsLeaf = false;
     if (_async)
     {
         return;
     }
     if (IsLeaf(node))
     {
         node.IsLeaf = true;
     }
 }
Пример #3
0
 /// <summary>
 /// 添加子节点
 /// </summary>
 private void AddChildren(ZorroTreeNode node)
 {
     if (node == null)
     {
         return;
     }
     node.Children = GetChildren(node.Key).Select(ToNode).ToList();
     foreach (var child in node.Children)
     {
         AddChildren(child);
     }
 }
Пример #4
0
        /// <summary>
        /// 转换为树节点
        /// </summary>
        protected virtual ZorroTreeNode ToNode(TreeDto dto)
        {
            var result = new ZorroTreeNode {
                Key             = dto.Id,
                Title           = dto.Text,
                Icon            = dto.Icon,
                Disabled        = !dto.Enabled.SafeValue(),
                Expanded        = dto.Expanded.SafeValue(),
                Checked         = dto.Checked.SafeValue(),
                DisableCheckbox = dto.DisableCheckbox.SafeValue(),
                Selectable      = dto.Selectable.SafeValue(),
                Selected        = dto.Selected.SafeValue()
            };

            InitIsLeaf(result);
            return(result);
        }