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); } } }
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; }); }
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; } }); }
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(); } }
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(); } }
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>(); })); }
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(); }
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); }
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(); } } } }
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(); }