Пример #1
0
 protected override ListResponse <TItem> OnViewProcessData(ListResponse <TItem> response)
 {
     response = base.OnViewProcessData(response);
     byId     = null;
     SlickTreeHelper.SetIndents(response.Entities, getId: x => x.Id, getParentId: x => x.ParentId, setCollapsed: GetInitialCollapse());
     return(response);
 }
Пример #2
0
        protected override bool OnViewFilter(TItem 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, TItem>();
                    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];
            }));
        }
Пример #3
0
        protected override void OnClick(jQueryEvent e, int row, int cell)
        {
            base.OnClick(e, row, cell);

            if (!e.IsDefaultPrevented())
            {
                SlickTreeHelper.ToggleClick(e, row, cell, view, x => x.Id);
            }

            if (e.IsDefaultPrevented())
            {
                return;
            }

            var target = J(e.Target);

            if (target.HasClass("check-box"))
            {
                bool checkedOrPartial = target.HasClass("checked") || target.HasClass("partial");
                var  item             = Rows[row];
                var  anyChanged       = item.IsSelected != (!checkedOrPartial);
                view.BeginUpdate();
                try
                {
                    if (item.IsSelected != !checkedOrPartial)
                    {
                        item.IsSelected = !checkedOrPartial;
                        view.UpdateItem(item.Id, item);
                        ItemSelectedChanged(item);
                    }
                    anyChanged = SetAllSubTreeSelected(item, item.IsSelected) | anyChanged;
                    UpdateSelectAll();
                    UpdateFlags();
                }
                finally
                {
                    view.EndUpdate();
                }

                if (anyChanged)
                {
                    this.element.TriggerHandler("change");
                }
            }
        }