public static void MakeOrderable(SlickGrid grid, Action <int[], int> handleMove) { var moveRowsPlugin = new SlickRowMoveManager(new SlickRowMoveManagerOptions { CancelEditOnDrag = true }); moveRowsPlugin.OnBeforeMoveRows.Subscribe((e, data) => { for (var i = 0; i < data.rows.length; i++) { if (data.rows[i] == data.insertBefore || data.rows[i] == data.insertBefore - 1) { e.StopPropagation(); return(false); } } return(true); }); moveRowsPlugin.OnMoveRows.Subscribe((e, data) => { int[] rows = data.rows; int insertBefore = data.insertBefore; handleMove(rows, insertBefore); try { grid.SetSelectedRows(new int[0]); } catch { } }); grid.RegisterPlugin(moveRowsPlugin); }
protected virtual SlickGrid CreateSlickGrid() { List <SlickColumn> slickColumns; if (this.IsAsyncWidget()) { slickColumns = new List <SlickColumn>(); } else { slickColumns = PostProcessColumns(GetColumns()); } var slickOptions = GetSlickOptions(); var grid = new SlickGrid(slickContainer, data: view.As <List <dynamic> >(), columns: slickColumns, options: slickOptions); grid.RegisterPlugin(new SlickAutoTooltips(new SlickAutoTooltipsOptions { EnableForHeaderCells = true })); this.slickGrid = grid; this.Rows = this.slickGrid.As <GridRows <TItem> >(); if (!IsAsyncWidget()) { SetInitialSortOrder(); } return(grid); }
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 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 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(); }
protected virtual SlickGrid CreateSlickGrid() { List <SlickColumn> slickColumns; if (this.IsAsyncWidget()) { slickColumns = new List <SlickColumn>(); } else { slickColumns = PostProcessColumns(GetColumns()); } var slickOptions = GetSlickOptions(); var self = this; dynamic viewRows = view.Rows; viewRows.getItemMetadata = new Func <int, dynamic>(delegate(int index) { var item = self.view.Rows[index]; return(self.GetItemMetadata(item, index)); }); var grid = new SlickGrid(slickContainer, data: viewRows, columns: slickColumns, options: slickOptions); grid.RegisterPlugin(new SlickAutoTooltips(new SlickAutoTooltipsOptions { EnableForHeaderCells = true })); this.slickGrid = grid; if (!IsAsyncWidget()) { SetInitialSortOrder(); } return(grid); }
protected virtual SlickGrid CreateSlickGrid() { var slickColumns = PostProcessColumns(GetColumns()); var slickOptions = GetSlickOptions(); var self = this; dynamic viewRows = view.Rows; viewRows.getItemMetadata = new Func <int, dynamic>(delegate(int index) { var item = self.view.Rows[index]; return(self.GetItemMetadata(item, index)); }); var grid = new SlickGrid(slickContainer, data: viewRows, columns: slickColumns, options: slickOptions); grid.RegisterPlugin(new SlickAutoTooltips(new SlickAutoTooltipsOptions { EnableForHeaderCells = true })); grid.SetSortColumns(GetDefaultSortBy().Map <SlickColumnSort>(s => { var x = new SlickColumnSort(); if (s != null && s.ToLower().EndsWith(" DESC")) { x.ColumnId = s.Substr(0, s.Length - 5); x.SortAsc = false; } else { x.ColumnId = s; x.SortAsc = true; } return(x); })); return(grid); }