コード例 #1
0
        public static void ToggleClick <TEntity>(jQueryEvent e, int row, int cell, SlickRemoteView <TEntity> view, Func <TEntity, object> getId)
        {
            var target = jQuery.FromElement(e.Target);

            if (!target.HasClass("s-TreeToggle"))
            {
                return;
            }

            if (target.HasClass("s-TreeCollapse") ||
                target.HasClass("s-TreeExpand"))
            {
                dynamic item = view.Rows[row];
                if (item != null)
                {
                    if (Q.IsFalse(item._collapsed))
                    {
                        item._collapsed = true;
                    }
                    else
                    {
                        item._collapsed = false;
                    }
                    view.UpdateItem(getId(item), item);
                }
            }
        }
コード例 #2
0
ファイル: GridUtils.cs プロジェクト: mhsabur/Serenity
        public static void AddIncludeDeletedToggle <TEntity>(jQueryObject toolDiv,
                                                             SlickRemoteView <TEntity> view, string hint = null, bool initial = false)
        {
            bool includeDeleted = false;

            var oldSubmit = view.OnSubmit;

            view.OnSubmit = (v) =>
            {
                v.Params.IncludeDeleted = includeDeleted;
                if (oldSubmit != null)
                {
                    return(oldSubmit(v));
                }

                return(true);
            };

            AddToggleButton(toolDiv,
                            cssClass: "s-IncludeDeletedToggle",
                            initial: initial,
                            hint: hint ?? "silinmiş kayıtları da göster",
                            callback: (pressed) =>
            {
                includeDeleted  = pressed;
                view.SeekToPage = 1;
                view.Populate();
            });

            toolDiv.Bind("remove", delegate
            {
                view.OnSubmit = null;
                oldSubmit     = null;
            });
        }
コード例 #3
0
        public static void AddQuickSearchInput <TEntity>(jQueryObject toolDiv,
                                                         SlickRemoteView <TEntity> view, List <QuickSearchField> fields = null)
        {
            var oldSubmit   = view.OnSubmit;
            var searchText  = "";
            var searchField = "";

            view.OnSubmit = (v) =>
            {
                if (searchText != null && searchText.Length > 0)
                {
                    v.Params.ContainsText = searchText;
                }
                else
                {
                    Script.Delete(v.Params, "ContainsText");
                }

                if (searchField != null && searchField.Length > 0)
                {
                    v.Params.ContainsField = searchField;
                }
                else
                {
                    Script.Delete(v.Params, "ContainsField");
                }

                if (oldSubmit != null)
                {
                    return(oldSubmit(v));
                }

                return(true);
            };

            Action <bool> lastDoneEvent = null;

            AddQuickSearchInputCustom(toolDiv, delegate(string field, string query, Action <bool> done)
            {
                searchText      = query;
                searchField     = field;
                view.SeekToPage = 1;
                lastDoneEvent   = done;
                view.Populate();
            }, fields);

            view.OnDataLoaded.Subscribe((e, ui) =>
            {
                if (lastDoneEvent != null)
                {
                    lastDoneEvent(view.Rows.Count > 0);
                    lastDoneEvent = null;
                }
            });
        }
コード例 #4
0
        public DataGrid(jQueryObject container, TOptions opt = null)
            : base(container, opt)
        {
            var self = this;

            this.element.AddClass("s-DataGrid").Html("");
            this.element.AddClass("s-" + this.GetType().Name);
            this.element.AddClass("require-layout").Bind("layout", delegate
            {
                self.Layout();
            });

            Title = GetInitialTitle();

            var buttons = GetButtons();

            if (buttons != null)
            {
                CreateToolbar(buttons);
            }

            this.slickContainer = CreateSlickContainer();

            this.view = CreateView();

            this.slickGrid = CreateSlickGrid();

            if (UsePager())
            {
                CreatePager();
            }

            BindToSlickEvents();
            BindToViewEvents();

            if (buttons != null)
            {
                CreateToolbarExtensions();
            }

            UpdateDisabledState();

            if (PopulateWhenVisible())
            {
                LazyLoadHelper.ExecuteEverytimeWhenShown(element, () => self.RefreshIfNeeded(), false);
                if (element.Is(":visible"))
                {
                    view.Populate();
                }
            }
            else
            {
                view.Populate();
            }
        }
コード例 #5
0
ファイル: DataGrid.cs プロジェクト: ganeshan/Serenity
        public DataGrid(jQueryObject container, TOptions opt = null)
            : base(container, opt)
        {
            var self = this;

            this.element.AddClass("s-DataGrid").Html("");
            this.element.AddClass("s-" + this.GetType().Name);
            this.element.AddClass("require-layout").Bind("layout", delegate
            {
                self.Layout();
            });

            Title = GetInitialTitle();

            var buttons = GetButtons();

            if (buttons != null)
            {
                CreateToolbar(buttons);
            }

            this.slickContainer = CreateSlickContainer();

            this.view = CreateView();

            this.slickGrid = CreateSlickGrid();

            if (EnableFiltering())
            {
                CreateFilterBar();
            }

            if (UsePager())
            {
                CreatePager();
            }

            BindToSlickEvents();
            BindToViewEvents();

            if (buttons != null)
            {
                CreateToolbarExtensions();
            }

            UpdateDisabledState();

            if (!IsAsyncWidget())
            {
                InitialPopulate();
            }
        }
コード例 #6
0
ファイル: SlickTreeHelper.cs プロジェクト: xareas/Serenity
        public static bool FilterById <TEntity>(TEntity item, SlickRemoteView <TEntity> view,
                                                Func <TEntity, object> getParentId)
            where TEntity : class
        {
            return(FilterCustom(item, x =>
            {
                var parentId = getParentId(x);

                if (parentId == null)
                {
                    return null;
                }

                return view.GetItemById(parentId).As <TEntity>();
            }));
        }
コード例 #7
0
ファイル: DataGrid.cs プロジェクト: ganeshan/Serenity
        public override void Destroy()
        {
            this.submitHandlers = null;

            if (this.toolbar != null)
            {
                this.toolbar.Destroy();
                this.toolbar = null;
            }

            if (this.slickGrid != null)
            {
                if (this.slickGridOnSort != null)
                {
                    this.slickGrid.OnSort.Unsubscribe(this.slickGridOnSort);
                    this.slickGridOnSort = null;
                }

                if (this.slickGridOnClick != null)
                {
                    this.slickGrid.OnSort.Unsubscribe(this.slickGridOnClick);
                    this.slickGridOnClick = null;
                }

                this.slickGrid.Destroy();
                this.slickGrid = null;
            }

            if (this.view != null)
            {
                this.view.OnRowsChanged.Clear();
                this.view.OnRowCountChanged.Clear();
                this.view.OnSubmit = null;
                this.view.SetFilter(null);
                dynamic viewRows = this.view.Rows;
                if (viewRows != null)
                {
                    viewRows.getItemMetadata = null;
                }
                this.view = null;
            }

            this.titleDiv = null;

            base.Destroy();
        }
コード例 #8
0
ファイル: GridUtils.cs プロジェクト: mhsabur/Serenity
        public static void AddQuickSearchInput <TEntity>(jQueryObject toolDiv,
                                                         SlickRemoteView <TEntity> view, List <QuickSearchField> fields = null)
        {
            var oldSubmit   = view.OnSubmit;
            var searchText  = "";
            var searchField = "";

            view.OnSubmit = (v) =>
            {
                if (searchText != null && searchText.Length > 0)
                {
                    v.Params.ContainsText = searchText;
                }
                else
                {
                    Script.Delete(v.Params, "ContainsText");
                }

                if (searchField != null && searchField.Length > 0)
                {
                    v.Params.ContainsField = searchField;
                }
                else
                {
                    Script.Delete(v.Params, "ContainsField");
                }

                if (oldSubmit != null)
                {
                    return(oldSubmit(v));
                }

                return(true);
            };

            AddQuickSearchInputCustom(toolDiv, delegate(string field, string query)
            {
                searchText      = query;
                searchField     = field;
                view.SeekToPage = 1;
                view.Populate();
            }, fields);
        }
コード例 #9
0
        public static void ToggleClick <TEntity>(jQueryEvent e, int row, int cell, SlickRemoteView <TEntity> view, Func <TEntity, object> getId)
        {
            var target = jQuery.FromElement(e.Target);

            if (!target.HasClass("s-TreeToggle"))
            {
                return;
            }

            if (target.HasClass("s-TreeCollapse") ||
                target.HasClass("s-TreeExpand"))
            {
                dynamic item = view.GetItem(row);
                if (item != null)
                {
                    if (Q.IsFalse(item._collapsed))
                    {
                        item._collapsed = true;
                    }
                    else
                    {
                        item._collapsed = false;
                    }
                    view.UpdateItem(getId(((object)item).As <TEntity>()), ((object)item).As <TEntity>());
                }

                if (e.ShiftKey)
                {
                    view.BeginUpdate();
                    try
                    {
                        SetCollapsed(view.GetItems(), item._collapsed);
                        view.SetItems(view.GetItems(), true);
                    }
                    finally
                    {
                        view.EndUpdate();
                    }
                }
            }
        }
コード例 #10
0
ファイル: DataGrid.cs プロジェクト: sunyruru/Serenity
        public override void Destroy()
        {
            this.submitHandlers = null;

            if (this.toolbar != null)
            {
                this.toolbar.Destroy();
                this.toolbar = null;
            }

            if (this.slickGrid != null)
            {
                if (this.slickGridOnSort != null)
                {
                    this.slickGrid.OnSort.Unsubscribe(this.slickGridOnSort);
                    this.slickGridOnSort = null;
                }

                if (this.slickGridOnClick != null)
                {
                    this.slickGrid.OnSort.Unsubscribe(this.slickGridOnClick);
                    this.slickGridOnClick = null;
                }

                this.slickGrid.Destroy();
                this.slickGrid = null;
            }

            if (this.view != null)
            {
                this.view.OnDataChanged.Clear();
                this.view.OnSubmit = null;
                this.view.SetFilter(null);
                this.view = null;
            }

            this.titleDiv = null;

            base.Destroy();
        }