Esempio n. 1
0
        protected override bool OnViewFilter(CheckTreeItem item)
        {
            if (!base.OnViewFilter(item))
            {
                return(false);
            }

            var items = view.GetItems();
            var self  = this;

            return(SlickTreeHelper.FilterCustom(item, x =>
            {
                if (x.ParentId == null)
                {
                    return null;
                }

                if (self.byId == null)
                {
                    self.byId = new JsDictionary <string, CheckTreeItem>();
                    for (var i = 0; i < items.Count; i++)
                    {
                        var o = items[i];
                        if (o.Id != null)
                        {
                            self.byId[o.Id] = o;
                        }
                    }
                }

                return self.byId[x.ParentId];
            }));
        }
Esempio n. 2
0
        private bool AllChildSelected(CheckTreeItem item)
        {
            for (int i = 0; i < item.Children.Count; i++)
            {
                if (!item.Children[i].IsSelected)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        protected bool AllSubTreeSelected(CheckTreeItem item)
        {
            if (item.Children.Count > 0)
            {
                for (int i = 0; i < item.Children.Count; i++)
                {
                    var sub = item.Children[i];
                    if (!sub.IsSelected)
                    {
                        return(false);
                    }
                    if (!AllSubTreeSelected(sub))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 4
0
        private bool SetAllSubTreeSelected(CheckTreeItem item, bool selected)
        {
            var result = false;

            for (int i = 0; i < item.Children.Count; i++)
            {
                var sub = item.Children[i];
                if (sub.IsSelected != selected)
                {
                    result         = true;
                    sub.IsSelected = selected;
                    view.UpdateItem(sub.Id, sub);
                }
                if (sub.Children.Count > 0)
                {
                    result = SetAllSubTreeSelected(sub, selected) | result;
                }
            }
            return(result);
        }