public static ToolButton CreateToolButton(IDataGrid grid, string service, Func<bool> onViewSubmit, string title = "Excel") { return new ToolButton { Title = title, CssClass = "export-xlsx-button", OnClick = delegate { if (!onViewSubmit()) return; var request = Q.DeepClone(((ListRequest)grid.GetView().Params)); request.Take = 0; request.Skip = 0; var sortBy = grid.GetView().SortBy; if (sortBy != null) request.Sort = sortBy; request.IncludeColumns = new List<string>(); foreach (var column in grid.GetGrid().GetColumns()) request.IncludeColumns.Add(column.Identifier ?? column.Field); Q.Externals.PostToService(new PostToServiceOptions { Service = service, Request = request, Target = "_blank" }); } }; }
public GridRowSelectionMixin(IDataGrid grid) { this.grid = grid; this.idField = grid.GetView().IdField; grid.GetGrid().OnClick.Subscribe((e, p) => { if (J(e.Target).HasClass("select-item")) { e.PreventDefault(); var item = grid.GetView().GetItem(p.row); var id = item[idField].toString(); if (include.ContainsKey(id)) include.Remove(id); else include[id] = true; for (var i = 0; i < grid.GetView().GetLength(); i++) grid.GetGrid().UpdateRow(i); UpdateSelectAll(); } }); grid.GetGrid().OnHeaderClick.Subscribe((e, u) => { if (e.IsDefaultPrevented()) return; if (J(e.Target).HasClass("select-all-items")) { e.PreventDefault(); var view = grid.GetView(); if (include.Count > 0) include.Clear(); else { foreach (var x in grid.GetView().GetItems()) { var id = x[idField]; include[id.toString()] = true; } } UpdateSelectAll(); grid.GetView().SetItems(grid.GetView().GetItems(), true); } }); grid.GetView().OnRowsChanged.Subscribe((e, u) => UpdateSelectAll()); }
public static ToolButton CreateToolButton(IDataGrid grid, string service, Func <bool> onViewSubmit, string title = "Excel") { return(new ToolButton { Title = title, CssClass = "export-xlsx-button", OnClick = delegate { if (!onViewSubmit()) { return; } var request = Q.DeepClone(((ListRequest)grid.GetView().Params)); request.Take = 0; request.Skip = 0; var sortBy = grid.GetView().SortBy; if (sortBy != null) { request.Sort = sortBy; } request.IncludeColumns = new List <string>(); foreach (var column in grid.GetGrid().GetColumns()) { request.IncludeColumns.Add(column.Identifier ?? column.Field); } Q.Externals.PostToService(new PostToServiceOptions { Service = service, Request = request, Target = "_blank" }); } }); }
public void ResetCheckedAndRefresh() { include = new JsDictionary <string, bool>(); UpdateSelectAll(); grid.GetView().Populate(); }
public GridRowSelectionMixin(IDataGrid grid) { this.grid = grid; this.idField = grid.GetView().IdField; grid.GetGrid().OnClick.Subscribe((e, p) => { if (J(e.Target).HasClass("select-item")) { e.PreventDefault(); var item = grid.GetView().GetItem(p.row); var id = item[idField].toString(); if (include.ContainsKey(id)) { include.Remove(id); } else { include[id] = true; } for (var i = 0; i < grid.GetView().GetLength(); i++) { grid.GetGrid().UpdateRow(i); } UpdateSelectAll(); } }); grid.GetGrid().OnHeaderClick.Subscribe((e, u) => { if (e.IsDefaultPrevented()) { return; } if (J(e.Target).HasClass("select-all-items")) { e.PreventDefault(); var view = grid.GetView(); if (include.Count > 0) { include.Clear(); } else { foreach (var x in grid.GetView().GetItems()) { var id = x[idField]; include[id.toString()] = true; } } UpdateSelectAll(); grid.GetView().SetItems(grid.GetView().GetItems(), true); } }); grid.GetView().OnRowsChanged.Subscribe((e, u) => UpdateSelectAll()); }