public async Task Invoke(HttpContext context) { _DbNetGridConfiguration = SerialisationHelper.DeserialiseJson <DbNetGridConfiguration>(context.Request.Body); // Db = new DbNetData(_DbNetGridConfiguration.ConnectionString, _DbNetGridConfiguration.DataProvider, _httpContextAccessor, _hostingEnvironment, _configuration); Db.Open(_DbNetGridConfiguration.ConnectionString, _DbNetGridConfiguration.DataProvider); var handler = (string)context.Request.Query["handler"] ?? string.Empty; switch (handler.ToLower()) { case "init": ConfigureColumns(); _DbNetGridConfiguration.Html["toolbar"] = await _viewRenderService.RenderToStringAsync("DbNetGrid", _DbNetGridConfiguration); GetPage(); _DbNetGridConfiguration.Html["page"] = await _viewRenderService.RenderToStringAsync("DbNetGrid_Page", _DbNetGridConfiguration); break; case "page": GetPage(); _DbNetGridConfiguration.Html["page"] = await _viewRenderService.RenderToStringAsync("DbNetGrid_Page", _DbNetGridConfiguration); break; } Db.Close(); context.Response.ContentType = "application/json"; await context.Response.WriteAsync(SerialisationHelper.SerialiseToJson(_DbNetGridConfiguration)); // await _next.Invoke(context); }
public async Task <IViewComponentResult> InvokeAsync(DbNetGridConfiguration configuration) { return(View(configuration)); }
public static List <SelectListItem> DropDownListFilter(this IHtmlHelper htmlHelper, DataColumn column, DbNetGridConfiguration configuration) { GridColumn gc = configuration.Columns.FirstOrDefault(c => c.ColumnName == column.ColumnName); if (gc.DropDownFilter == false || string.IsNullOrEmpty(gc.Lookup)) { return(null); } var options = gc.LookupData.Select(a => new SelectListItem { Value = a.Key, Text = a.Value }).OrderBy(s => s.Text).ToList(); if (column.ColumnName == configuration.DropDownFilterColumn) { options.Where(o => o.Value == configuration.DropDownFilterValue).ToList().ForEach(o => o.Selected = true); } return(options); }
public static IHtmlContent CellHeading(this IHtmlHelper htmlHelper, DataColumn column, DbNetGridConfiguration configuration) { GridColumn gc = configuration.Columns.FirstOrDefault(c => c.ColumnName == column.ColumnName); string heading = $"<span>{(string.IsNullOrEmpty(gc.Label) ? gc.ColumnName : gc.Label)}</span>"; if (configuration.OrderByColumn == column.ColumnName) { heading += $"<img sequence=\"{configuration.OrderBySequence}\" src=\"{ResourceHelper.DataUrl($"chevron-{(configuration.OrderBySequence == "asc" ? "up" : "down")}")}\"/>"; } return(new HtmlString(heading)); }