diff --git a/GridBlazor/CGrid.cs b/GridBlazor/CGrid.cs index 777cd358..f23407cb 100644 --- a/GridBlazor/CGrid.cs +++ b/GridBlazor/CGrid.cs @@ -1141,13 +1141,13 @@ private async Task GetItemsDTO() try { ItemsDTO response; - if (_dataService != null) + if (_dataServiceAsync != null) { - response = _dataService((QueryDictionary)_query); + response = await _dataServiceAsync(_query); } - else if (_dataServiceAsync != null) + else if (_dataService != null) { - response = await _dataServiceAsync((QueryDictionary)_query); + response = _dataService(_query); } else { diff --git a/GridBlazor/GridBlazor.csproj b/GridBlazor/GridBlazor.csproj index 8fc82fe9..253ea7d1 100644 --- a/GridBlazor/GridBlazor.csproj +++ b/GridBlazor/GridBlazor.csproj @@ -6,7 +6,7 @@ 8.0 True False - 3.2.2 + 3.2.3 GridBlazor Grid components for Blazor Grid components for Blazor diff --git a/GridBlazorClientSide.Client/GridBlazorClientSide.Client.csproj b/GridBlazorClientSide.Client/GridBlazorClientSide.Client.csproj index 57600eae..66fbe44e 100644 --- a/GridBlazorClientSide.Client/GridBlazorClientSide.Client.csproj +++ b/GridBlazorClientSide.Client/GridBlazorClientSide.Client.csproj @@ -2,7 +2,7 @@ net6.0 - 3.2.2 + 3.2.3 true diff --git a/GridBlazorClientSide.Client/Pages/ButtonCrud.razor b/GridBlazorClientSide.Client/Pages/ButtonCrud.razor index 3b77b4af..feee37a8 100644 --- a/GridBlazorClientSide.Client/Pages/ButtonCrud.razor +++ b/GridBlazorClientSide.Client/Pages/ButtonCrud.razor @@ -36,7 +36,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -106,12 +106,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorClientSide.Client/Pages/Crud.razor b/GridBlazorClientSide.Client/Pages/Crud.razor index 12bcc2eb..25f5cc13 100644 --- a/GridBlazorClientSide.Client/Pages/Crud.razor +++ b/GridBlazorClientSide.Client/Pages/Crud.razor @@ -36,7 +36,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -104,12 +104,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorClientSide.Client/Pages/NestedCrud.razor b/GridBlazorClientSide.Client/Pages/NestedCrud.razor index ecea6553..feb1c583 100644 --- a/GridBlazorClientSide.Client/Pages/NestedCrud.razor +++ b/GridBlazorClientSide.Client/Pages/NestedCrud.razor @@ -40,7 +40,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -127,12 +127,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorClientSide.Client/Pages/NestedCrudCreateGrid.razor b/GridBlazorClientSide.Client/Pages/NestedCrudCreateGrid.razor index d677f6d3..91ddcefc 100644 --- a/GridBlazorClientSide.Client/Pages/NestedCrudCreateGrid.razor +++ b/GridBlazorClientSide.Client/Pages/NestedCrudCreateGrid.razor @@ -39,7 +39,7 @@ else private GridComponent _gridComponent; private OrderDetailMemoryService _orderDetailMemoryService; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; protected override async Task OnParametersSetAsync() { @@ -90,10 +90,10 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.AfterInsert += AfterInsert; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorClientSide.Server/Controllers/SampleDataController.cs b/GridBlazorClientSide.Server/Controllers/SampleDataController.cs index 6faa9032..dc4a29df 100644 --- a/GridBlazorClientSide.Server/Controllers/SampleDataController.cs +++ b/GridBlazorClientSide.Server/Controllers/SampleDataController.cs @@ -24,7 +24,7 @@ public SampleDataController(NorthwindDbContext context) } [HttpGet("[action]")] - public ActionResult GetOrdersGrid() + public async Task GetOrdersGrid() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -36,7 +36,7 @@ public ActionResult GetOrdersGrid() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -59,7 +59,7 @@ public ActionResult GetOrdersGridordersAutoGenerateColumns() } [HttpGet("[action]")] - public ActionResult GetOrdersGridWithTotals() + public async Task GetOrdersGridWithTotals() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -71,7 +71,7 @@ public ActionResult GetOrdersGridWithTotals() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -93,7 +93,7 @@ public ActionResult GetOrdersGridWithCount() } [HttpGet("[action]")] - public ActionResult GetOrdersGridSearchable() + public async Task GetOrdersGridSearchable() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -106,12 +106,12 @@ public ActionResult GetOrdersGridSearchable() .Searchable(true, false, false) .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult GetOrdersGridExtSorting() + public async Task GetOrdersGridExtSorting() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -124,12 +124,12 @@ public ActionResult GetOrdersGridExtSorting() .Groupable(true) .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult GetOrdersGridGroupable() + public async Task GetOrdersGridGroupable() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -142,7 +142,7 @@ public ActionResult GetOrdersGridGroupable() .Groupable(true) .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -173,7 +173,7 @@ public ActionResult GetMinFreight(string clientName) } [HttpGet("[action]")] - public ActionResult GetOrdersGridWithSubgrids() + public async Task GetOrdersGridWithSubgrids() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -184,13 +184,13 @@ public ActionResult GetOrdersGridWithSubgrids() .WithMultipleFilters() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult OrderColumnsListFilter() + public async Task OrderColumnsListFilter() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -202,12 +202,12 @@ public ActionResult OrderColumnsListFilter() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult OrderColumnsWithEdit() + public async Task OrderColumnsWithEdit() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -219,12 +219,12 @@ public ActionResult OrderColumnsWithEdit() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult OrderColumnsWithCrud() + public async Task OrderColumnsWithCrud() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -236,12 +236,12 @@ public ActionResult OrderColumnsWithCrud() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult OrderColumnsWithSubgridCrud() + public async Task OrderColumnsWithSubgridCrud() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -253,7 +253,7 @@ public ActionResult OrderColumnsWithSubgridCrud() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -279,7 +279,7 @@ public ActionResult GetOrderColumnsWithErrors() } [HttpGet("[action]")] - public ActionResult GetOrdersGridAllFeatures() + public async Task GetOrdersGridAllFeatures() { var repository = new OrdersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -291,7 +291,7 @@ public ActionResult GetOrdersGridAllFeatures() .Searchable(true, false) .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -361,7 +361,7 @@ public ActionResult GetAllProducts() } [HttpGet("[action]")] - public ActionResult GetOrderDetailsGrid(int OrderId) + public async Task GetOrderDetailsGrid(int OrderId) { var orderDetails = (new OrderDetailsRepository(_context)).GetForOrder(OrderId); @@ -373,12 +373,12 @@ public ActionResult GetOrderDetailsGrid(int OrderId) .WithMultipleFilters() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult GetOrderDetailsGridWithCrud(int OrderId) + public async Task GetOrderDetailsGridWithCrud(int OrderId) { var orderDetails = (new OrderDetailsRepository(_context)).GetForOrder(OrderId); @@ -390,12 +390,12 @@ public ActionResult GetOrderDetailsGridWithCrud(int OrderId) .WithMultipleFilters() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult GetOrderDetailsGridAllFeatures(int OrderId) + public async Task GetOrderDetailsGridAllFeatures(int OrderId) { var orderDetails = (new OrderDetailsRepository(_context)).GetForOrder(OrderId); @@ -407,12 +407,12 @@ public ActionResult GetOrderDetailsGridAllFeatures(int OrderId) .WithMultipleFilters() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } [HttpGet("[action]")] - public ActionResult GetCustomersGrid() + public async Task GetCustomersGrid() { var repository = new CustomersRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -424,7 +424,7 @@ public ActionResult GetCustomersGrid() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } @@ -493,7 +493,7 @@ public async Task Subtract1ToFreight(int id) } [HttpGet("[action]")] - public ActionResult GetEmployeesGrid() + public async Task GetEmployeesGrid() { var repository = new EmployeeRepository(_context); IGridServer server = new GridCoreServer(repository.GetAll(), Request.Query, @@ -505,7 +505,7 @@ public ActionResult GetEmployeesGrid() .WithGridItemsCount() .SetRemoveDiacritics("RemoveDiacritics"); - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return Ok(items); } diff --git a/GridBlazorClientSide.Server/GridBlazorClientSide.Server.csproj b/GridBlazorClientSide.Server/GridBlazorClientSide.Server.csproj index ac0aebc2..1b539375 100644 --- a/GridBlazorClientSide.Server/GridBlazorClientSide.Server.csproj +++ b/GridBlazorClientSide.Server/GridBlazorClientSide.Server.csproj @@ -3,7 +3,7 @@ net6.0 true - 3.0.4 + 3.2.3 diff --git a/GridBlazorOData.Client/GridBlazorOData.Client.csproj b/GridBlazorOData.Client/GridBlazorOData.Client.csproj index 95771961..9cef0f16 100644 --- a/GridBlazorOData.Client/GridBlazorOData.Client.csproj +++ b/GridBlazorOData.Client/GridBlazorOData.Client.csproj @@ -2,7 +2,7 @@ net6.0 - 3.2.2 + 3.2.3 true diff --git a/GridBlazorOData.Client/Pages/ButtonCrud.razor b/GridBlazorOData.Client/Pages/ButtonCrud.razor index 0ddfb02a..bc98dd75 100644 --- a/GridBlazorOData.Client/Pages/ButtonCrud.razor +++ b/GridBlazorOData.Client/Pages/ButtonCrud.razor @@ -37,7 +37,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -129,12 +129,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorOData.Client/Pages/Crud.razor b/GridBlazorOData.Client/Pages/Crud.razor index d4760441..c3cb93b6 100644 --- a/GridBlazorOData.Client/Pages/Crud.razor +++ b/GridBlazorOData.Client/Pages/Crud.razor @@ -37,7 +37,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -127,12 +127,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorOData.Client/Pages/NestedCrud.razor b/GridBlazorOData.Client/Pages/NestedCrud.razor index 00ba7b63..e9614b6a 100644 --- a/GridBlazorOData.Client/Pages/NestedCrud.razor +++ b/GridBlazorOData.Client/Pages/NestedCrud.razor @@ -40,7 +40,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -220,12 +220,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorOData.Client/Pages/NestedCrudCreateGrid.razor b/GridBlazorOData.Client/Pages/NestedCrudCreateGrid.razor index 55b41d97..d6364888 100644 --- a/GridBlazorOData.Client/Pages/NestedCrudCreateGrid.razor +++ b/GridBlazorOData.Client/Pages/NestedCrudCreateGrid.razor @@ -41,7 +41,7 @@ else private GridComponent _gridComponent; private OrderDetailMemoryService _orderDetailMemoryService; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; protected override async Task OnParametersSetAsync() { @@ -189,10 +189,10 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.AfterInsert += AfterInsert; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/GridBlazorServerSide.csproj b/GridBlazorServerSide/GridBlazorServerSide.csproj index 52b219f1..5f92586c 100644 --- a/GridBlazorServerSide/GridBlazorServerSide.csproj +++ b/GridBlazorServerSide/GridBlazorServerSide.csproj @@ -2,7 +2,7 @@ net6.0 - 3.2.2 + 3.2.3 diff --git a/GridBlazorServerSide/Pages/ButtonCrud.razor b/GridBlazorServerSide/Pages/ButtonCrud.razor index 4f8a95f2..b38d7d8b 100644 --- a/GridBlazorServerSide/Pages/ButtonCrud.razor +++ b/GridBlazorServerSide/Pages/ButtonCrud.razor @@ -42,6 +42,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -58,7 +59,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithCrud(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() @@ -110,11 +111,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/ChangePageSize.razor b/GridBlazorServerSide/Pages/ChangePageSize.razor index 81eac5b7..ba3a9390 100644 --- a/GridBlazorServerSide/Pages/ChangePageSize.razor +++ b/GridBlazorServerSide/Pages/ChangePageSize.razor @@ -42,7 +42,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Checkbox.razor b/GridBlazorServerSide/Pages/Checkbox.razor index 278b47d8..e89cb45b 100644 --- a/GridBlazorServerSide/Pages/Checkbox.razor +++ b/GridBlazorServerSide/Pages/Checkbox.razor @@ -47,7 +47,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsCheckbox, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsCheckbox, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsCheckbox, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Crud.razor b/GridBlazorServerSide/Pages/Crud.razor index 44547f14..cc2a3656 100644 --- a/GridBlazorServerSide/Pages/Crud.razor +++ b/GridBlazorServerSide/Pages/Crud.razor @@ -42,6 +42,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -58,7 +59,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithCrud(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() @@ -108,11 +109,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/CustomCrud.razor b/GridBlazorServerSide/Pages/CustomCrud.razor index ee0535ec..071c9a28 100644 --- a/GridBlazorServerSide/Pages/CustomCrud.razor +++ b/GridBlazorServerSide/Pages/CustomCrud.razor @@ -48,7 +48,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithCustomCrud(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/CustomerComponent.razor b/GridBlazorServerSide/Pages/CustomerComponent.razor index a5f44c72..bcefb5fe 100644 --- a/GridBlazorServerSide/Pages/CustomerComponent.razor +++ b/GridBlazorServerSide/Pages/CustomerComponent.razor @@ -48,7 +48,7 @@ else var query = new QueryDictionary(); - var client = new GridClient(q => customerService.GetCustomersGridRows(ColumnCollections.CustomerColumns, q), + var client = new GridClient(q => customerService.GetCustomersGridRowsAsync(ColumnCollections.CustomerColumns, q), query, false, "customersGrid", ColumnCollections.CustomerColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/EditRows.razor b/GridBlazorServerSide/Pages/EditRows.razor index 183ce9d9..d579d227 100644 --- a/GridBlazorServerSide/Pages/EditRows.razor +++ b/GridBlazorServerSide/Pages/EditRows.razor @@ -64,7 +64,7 @@ else } } - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Embedded.razor b/GridBlazorServerSide/Pages/Embedded.razor index bb8f0b10..3600d062 100644 --- a/GridBlazorServerSide/Pages/Embedded.razor +++ b/GridBlazorServerSide/Pages/Embedded.razor @@ -45,7 +45,7 @@ else //query.Add("grid-filter", "Customer.Country__1__usa"); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsWithButttonComponents, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsWithButttonComponents, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsWithButttonComponents, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/EmployeeComponent.razor b/GridBlazorServerSide/Pages/EmployeeComponent.razor index a3a0b2b8..3bc75153 100644 --- a/GridBlazorServerSide/Pages/EmployeeComponent.razor +++ b/GridBlazorServerSide/Pages/EmployeeComponent.razor @@ -45,7 +45,7 @@ else var query = new QueryDictionary(); - var client = new GridClient(q => employeeService.GetEmployeesGridRows(ColumnCollections.EmployeeColumns, q), + var client = new GridClient(q => employeeService.GetEmployeesGridRowsAsync(ColumnCollections.EmployeeColumns, q), query, false, "employeesGrid", ColumnCollections.EmployeeColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Excel.razor b/GridBlazorServerSide/Pages/Excel.razor index db32d7cc..6837224f 100644 --- a/GridBlazorServerSide/Pages/Excel.razor +++ b/GridBlazorServerSide/Pages/Excel.razor @@ -45,7 +45,7 @@ else //query.Add("grid-filter", "Customer.Country__1__usa"); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/ExtSorting.razor b/GridBlazorServerSide/Pages/ExtSorting.razor index def47ed8..73223d50 100644 --- a/GridBlazorServerSide/Pages/ExtSorting.razor +++ b/GridBlazorServerSide/Pages/ExtSorting.razor @@ -37,6 +37,7 @@ else { private CGrid _grid; private Task _task; + private bool _afterRenderExecuted = false; protected override async Task OnParametersSetAsync() { @@ -44,7 +45,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsExtSorting, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsExtSorting, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsExtSorting, locale) .Sortable() .Filterable() @@ -61,11 +62,12 @@ else protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { var payloads = new List(); payloads.Add(new ColumnOrderValue("Customer.CompanyName", GridSortDirection.Ascending, 1)); await _grid.GridComponent.InitExtSorting(payloads); + _afterRenderExecuted = true; } } } diff --git a/GridBlazorServerSide/Pages/GridSample.razor b/GridBlazorServerSide/Pages/GridSample.razor index c308b8f3..e053540f 100644 --- a/GridBlazorServerSide/Pages/GridSample.razor +++ b/GridBlazorServerSide/Pages/GridSample.razor @@ -60,6 +60,7 @@ else private OrderIDetaillnfo _orderDetailInfo; private IQueryDictionary _customFilters = new QueryDictionary(); private List> _rowClickActions; + private bool _afterRenderExecuted = false; [Parameter] public string GridState { get; set; } @@ -80,7 +81,7 @@ else Action> subGridColumns = c => ColumnCollections.OrderDetailColumnsCrud(c, productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .Sortable() .Filterable() @@ -101,7 +102,7 @@ else productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .SetRowCssClasses(item => item.Quantity > 10 ? "success" : string.Empty) .Sortable() @@ -133,7 +134,7 @@ else // do nothing, GridState was not a valid state } } - var client = new GridClient(q => orderService.GetOrdersGridRows(orderColumns, q), query, false, + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(orderColumns, q), query, false, "ordersGrid", orderColumns, locale) .SetRowCssClasses(item => item.Customer.IsVip ? "success" : string.Empty) .Sortable() @@ -161,7 +162,7 @@ else protected override void OnAfterRender(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { _gridComponent.PagerChanged += PagerChanged; _gridComponent.SortChanged += SortChanged; @@ -170,6 +171,7 @@ else _gridComponent.SearchChanged += SearchChanged; _gridComponent.BeforeRefreshGrid += BeforeRefreshGrid; _gridComponent.AfterRefreshGrid += AfterRefreshGrid; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/Groupable.razor b/GridBlazorServerSide/Pages/Groupable.razor index e32e8c4c..0ed69752 100644 --- a/GridBlazorServerSide/Pages/Groupable.razor +++ b/GridBlazorServerSide/Pages/Groupable.razor @@ -37,6 +37,7 @@ else { private CGrid _grid; private Task _task; + private bool _afterRenderExecuted = false; protected override async Task OnParametersSetAsync() { @@ -45,7 +46,7 @@ else var query = new QueryDictionary(); Action> columns = c => ColumnCollections.OrderColumnsGroupable(c, SetCustomerNameLabel); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() @@ -62,12 +63,13 @@ else protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { var payloads = new List(); payloads.Add(new ColumnOrderValue("Customer.CompanyName", GridSortDirection.Ascending, 1)); payloads.Add(new ColumnOrderValue("ShipVia", GridSortDirection.Ascending, 2)); await _grid.GridComponent.InitGrouping(payloads); + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/HeaderCrudButtons.razor b/GridBlazorServerSide/Pages/HeaderCrudButtons.razor index 7c3a6d16..e3009d82 100644 --- a/GridBlazorServerSide/Pages/HeaderCrudButtons.razor +++ b/GridBlazorServerSide/Pages/HeaderCrudButtons.razor @@ -62,7 +62,7 @@ else Action> subGridColumns = c => ColumnCollections.OrderDetailColumnsCrud(c, productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .Sortable() .Filterable() @@ -83,7 +83,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithNestedCrud(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers, subGrids); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Index.razor b/GridBlazorServerSide/Pages/Index.razor index 1e367910..35505378 100644 --- a/GridBlazorServerSide/Pages/Index.razor +++ b/GridBlazorServerSide/Pages/Index.razor @@ -45,7 +45,7 @@ else //query.Add("grid-filter", "Customer.Country__1__usa"); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/KeyboardNav.razor b/GridBlazorServerSide/Pages/KeyboardNav.razor index cd9a8b7f..8f6a98c3 100644 --- a/GridBlazorServerSide/Pages/KeyboardNav.razor +++ b/GridBlazorServerSide/Pages/KeyboardNav.razor @@ -63,7 +63,7 @@ else // do nothing, GridState was not a valid state } } - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/ListFilter.razor b/GridBlazorServerSide/Pages/ListFilter.razor index 8e495da0..5a34f93a 100644 --- a/GridBlazorServerSide/Pages/ListFilter.razor +++ b/GridBlazorServerSide/Pages/ListFilter.razor @@ -47,7 +47,7 @@ else Action> columns = c => ColumnCollections .OrderColumnsListFilter(c, customerService.GetAllCustomers2(), customerService.GetAllContacts(), shipperService.GetAllShippers()); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/MultipleGrids.razor b/GridBlazorServerSide/Pages/MultipleGrids.razor index 15ac0906..67ebe9a8 100644 --- a/GridBlazorServerSide/Pages/MultipleGrids.razor +++ b/GridBlazorServerSide/Pages/MultipleGrids.razor @@ -84,7 +84,7 @@ else // do nothing, GridState was not a valid state } } - var ordersClient = new GridClient(q => orderService.GetOrdersGridRows(orderColumns, q), + var ordersClient = new GridClient(q => orderService.GetOrdersGridRowsAsync(orderColumns, q), ordersQuery, false, "ordersGrid", orderColumns, locale) .Sortable() .Filterable() @@ -109,7 +109,7 @@ else // do nothing, GridState was not a valid state } } - var customersClient = new GridClient(q => customerService.GetCustomersGridRows(ColumnCollections.CustomersColumns, q), + var customersClient = new GridClient(q => customerService.GetCustomersGridRowsAsync(ColumnCollections.CustomersColumns, q), customersQuery, false, "customersGrid", ColumnCollections.CustomersColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/NestedCrud.razor b/GridBlazorServerSide/Pages/NestedCrud.razor index a688ba10..e8963198 100644 --- a/GridBlazorServerSide/Pages/NestedCrud.razor +++ b/GridBlazorServerSide/Pages/NestedCrud.razor @@ -44,7 +44,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -64,7 +64,7 @@ else Action> subGridColumns = c => ColumnCollections.OrderDetailColumnsCrud(c, productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .Sortable() .Filterable() @@ -84,7 +84,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithNestedCrud(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers, subGrids); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() @@ -132,12 +132,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/NestedCrudCreateGrid.razor b/GridBlazorServerSide/Pages/NestedCrudCreateGrid.razor index feb70021..6b113d23 100644 --- a/GridBlazorServerSide/Pages/NestedCrudCreateGrid.razor +++ b/GridBlazorServerSide/Pages/NestedCrudCreateGrid.razor @@ -42,7 +42,7 @@ else private GridComponent _gridComponent; private OrderDetailMemoryService _orderDetailMemoryService; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; protected override async Task OnParametersSetAsync() { @@ -58,7 +58,7 @@ else var products = productService.GetAllProducts(); _orderDetailMemoryService = new OrderDetailMemoryService(subGridColumns, products); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), _orderDetailMemoryService, subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .Sortable() .Filterable() @@ -76,7 +76,7 @@ else Action> columns = c => ColumnCollections.OrderColumnsWithCreateGrid(c, c => customerService.GetAllCustomers(), c => employeeService.GetAllEmployees(), shipperService.GetAllShippers, subGrids); - var client = new GridClient(q => orderService.GetOrdersGridRows(columns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(columns, q), query, false, "ordersGrid", columns, locale) .Sortable() .Filterable() @@ -94,10 +94,10 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.AfterInsert += AfterInsert; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/OrderDetailsComponent.razor b/GridBlazorServerSide/Pages/OrderDetailsComponent.razor index ddfe358e..cbe5ca62 100644 --- a/GridBlazorServerSide/Pages/OrderDetailsComponent.razor +++ b/GridBlazorServerSide/Pages/OrderDetailsComponent.razor @@ -48,7 +48,7 @@ var query = new QueryDictionary(); - var client = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(ColumnCollections.OrderDetailColumns, + var client = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(ColumnCollections.OrderDetailColumns, new object[] { _order.OrderID }, q), query, false, "orderDetailsGrid", ColumnCollections.OrderDetailColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/RTL.razor b/GridBlazorServerSide/Pages/RTL.razor index 7478076c..de99530f 100644 --- a/GridBlazorServerSide/Pages/RTL.razor +++ b/GridBlazorServerSide/Pages/RTL.razor @@ -46,6 +46,7 @@ else private GridComponent _gridComponent; private Task _task; private IQueryDictionary _customFilters = new QueryDictionary(); + private bool _afterRenderExecuted = false; [Parameter] public string GridState { get; set; } @@ -62,7 +63,7 @@ else Action> subGridColumns = c => ColumnCollections.OrderDetailColumnsCrud(c, productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .Sortable() .Filterable() @@ -83,7 +84,7 @@ else productService.GetAllProducts); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(subGridColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(subGridColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), subGridColumns, locale) .SetRowCssClasses(item => item.Quantity > 10 ? "success" : string.Empty) .Sortable() @@ -115,7 +116,7 @@ else // do nothing, GridState was not a valid state } } - var client = new GridClient(q => orderService.GetOrdersGridRows(orderColumns, q), query, false, + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(orderColumns, q), query, false, "ordersGrid", orderColumns, locale) .SetRowCssClasses(item => item.Customer.IsVip ? "success" : string.Empty) .Sortable() @@ -144,7 +145,7 @@ else protected override void OnAfterRender(bool firstRender) { - if (firstRender) + if (!_afterRenderExecuted && _grid.GridComponent != null) { _gridComponent.PagerChanged += PagerChanged; _gridComponent.SortChanged += SortChanged; @@ -153,6 +154,7 @@ else _gridComponent.SearchChanged += SearchChanged; _gridComponent.BeforeRefreshGrid += BeforeRefreshGrid; _gridComponent.AfterRefreshGrid += AfterRefreshGrid; + _afterRenderExecuted = true; } } diff --git a/GridBlazorServerSide/Pages/RearrangeableColumns.razor b/GridBlazorServerSide/Pages/RearrangeableColumns.razor index 05dd4419..37a9810c 100644 --- a/GridBlazorServerSide/Pages/RearrangeableColumns.razor +++ b/GridBlazorServerSide/Pages/RearrangeableColumns.razor @@ -42,7 +42,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsRearrangeable, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsRearrangeable, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsRearrangeable, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Searchable.razor b/GridBlazorServerSide/Pages/Searchable.razor index bda06cf6..fc0b52ea 100644 --- a/GridBlazorServerSide/Pages/Searchable.razor +++ b/GridBlazorServerSide/Pages/Searchable.razor @@ -43,7 +43,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Selectable.razor b/GridBlazorServerSide/Pages/Selectable.razor index 2e64ea08..24850eee 100644 --- a/GridBlazorServerSide/Pages/Selectable.razor +++ b/GridBlazorServerSide/Pages/Selectable.razor @@ -64,7 +64,7 @@ else // do nothing, GridState was not a valid state } } - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumns, q), query, false, "ordersGrid", ColumnCollections.OrderColumns, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/SubGrid.razor b/GridBlazorServerSide/Pages/SubGrid.razor index 1eea8666..560c4aef 100644 --- a/GridBlazorServerSide/Pages/SubGrid.razor +++ b/GridBlazorServerSide/Pages/SubGrid.razor @@ -46,7 +46,7 @@ else Func> subGrids = async keys => { var subGridQuery = new QueryDictionary(); - var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRows(ColumnCollections.OrderDetailColumns, keys, q), + var subGridClient = new GridClient(q => orderDetailService.GetOrderDetailsGridRowsAsync(ColumnCollections.OrderDetailColumns, keys, q), subGridQuery, false, "orderDetailsGrid" + keys[0].ToString(), ColumnCollections.OrderDetailColumns, locale) .Sortable() .Filterable() @@ -59,7 +59,7 @@ else }; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsWithSubgrids, q), query, + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsWithSubgrids, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsWithSubgrids, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Pages/Totals.razor b/GridBlazorServerSide/Pages/Totals.razor index c072e1e4..47c68a6c 100644 --- a/GridBlazorServerSide/Pages/Totals.razor +++ b/GridBlazorServerSide/Pages/Totals.razor @@ -43,7 +43,7 @@ else SharedResource.Culture = locale; var query = new QueryDictionary(); - var client = new GridClient(q => orderService.GetOrdersGridRows(ColumnCollections.OrderColumnsWithTotals, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(ColumnCollections.OrderColumnsWithTotals, q), query, false, "ordersGrid", ColumnCollections.OrderColumnsWithTotals, locale) .Sortable() .Filterable() diff --git a/GridBlazorServerSide/Services/CustomerService.cs b/GridBlazorServerSide/Services/CustomerService.cs index d36e89ed..123dac70 100644 --- a/GridBlazorServerSide/Services/CustomerService.cs +++ b/GridBlazorServerSide/Services/CustomerService.cs @@ -63,7 +63,7 @@ public IEnumerable GetAllContacts() } } - public ItemsDTO GetCustomersGridRows(Action> columns, + public async Task> GetCustomersGridRowsAsync(Action> columns, QueryDictionary query) { using (var context = new NorthwindDbContext(_options)) @@ -78,7 +78,7 @@ public ItemsDTO GetCustomersGridRows(Action("RemoveDiacritics"); // return items to displays - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return items; } } @@ -151,6 +151,7 @@ public interface ICustomerService : ICrudDataService IEnumerable GetAllCustomers(); IEnumerable GetAllCustomers2(); IEnumerable GetAllContacts(); - ItemsDTO GetCustomersGridRows(Action> columns, QueryDictionary query); + Task> GetCustomersGridRowsAsync(Action> columns, + QueryDictionary query); } } diff --git a/GridBlazorServerSide/Services/EmployeeService.cs b/GridBlazorServerSide/Services/EmployeeService.cs index 5f0173dc..050adf4e 100644 --- a/GridBlazorServerSide/Services/EmployeeService.cs +++ b/GridBlazorServerSide/Services/EmployeeService.cs @@ -21,7 +21,7 @@ public EmployeeService(DbContextOptions options) _options = options; } - public ItemsDTO GetEmployeesGridRows(Action> columns, + public async Task> GetEmployeesGridRowsAsync(Action> columns, QueryDictionary query) { using (var context = new NorthwindDbContext(_options)) @@ -37,7 +37,7 @@ public ItemsDTO GetEmployeesGridRows(Action("RemoveDiacritics"); // return items to displays - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return items; } } @@ -120,7 +120,7 @@ public async Task Delete(params object[] keys) public interface IEmployeeService : ICrudDataService { - ItemsDTO GetEmployeesGridRows(Action> columns, + Task> GetEmployeesGridRowsAsync(Action> columns, QueryDictionary query); IEnumerable GetAllEmployees(); } diff --git a/GridBlazorServerSide/Services/OrderDetailService.cs b/GridBlazorServerSide/Services/OrderDetailService.cs index c83a38ed..bb0f5830 100644 --- a/GridBlazorServerSide/Services/OrderDetailService.cs +++ b/GridBlazorServerSide/Services/OrderDetailService.cs @@ -19,7 +19,7 @@ public OrderDetailService(DbContextOptions options) _options = options; } - public ItemsDTO GetOrderDetailsGridRows(Action> columns, + public async Task> GetOrderDetailsGridRowsAsync(Action> columns, object[] keys, QueryDictionary query) { using (var context = new NorthwindDbContext(_options)) @@ -35,7 +35,7 @@ public ItemsDTO GetOrderDetailsGridRows(Action("RemoveDiacritics"); // return items to displays - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return items; } } @@ -108,7 +108,7 @@ public async Task Delete(params object[] keys) public interface IOrderDetailService : ICrudDataService { - ItemsDTO GetOrderDetailsGridRows(Action> columns, + Task> GetOrderDetailsGridRowsAsync(Action> columns, object[] keys, QueryDictionary query); } } diff --git a/GridBlazorServerSide/Services/OrderService.cs b/GridBlazorServerSide/Services/OrderService.cs index e320e8db..cad60307 100644 --- a/GridBlazorServerSide/Services/OrderService.cs +++ b/GridBlazorServerSide/Services/OrderService.cs @@ -20,7 +20,7 @@ public OrderService(DbContextOptions options) _options = options; } - public ItemsDTO GetOrdersGridRows(Action> columns, + public async Task> GetOrdersGridRowsAsync(Action> columns, QueryDictionary query) { using (var context = new NorthwindDbContext(_options)) @@ -37,7 +37,7 @@ public ItemsDTO GetOrdersGridRows(Action> co .SetRemoveDiacritics("RemoveDiacritics"); // return items to displays - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); // uncomment the following lines are to test null responses //items = null; @@ -300,7 +300,7 @@ public async Task Delete(params object[] keys) public interface IOrderService : ICrudDataService { - ItemsDTO GetOrdersGridRows(Action> columns, QueryDictionary query); + Task> GetOrdersGridRowsAsync(Action> columns, QueryDictionary query); ItemsDTO GetOrdersGridRowsWithCount(Action> columns, QueryDictionary query); ItemsDTO GetOrdersGridRows(QueryDictionary query); ItemsDTO GetOrdersGridRowsInMemory(Action> columns, QueryDictionary query); diff --git a/GridBlazorStandalone/GridBlazorStandalone.csproj b/GridBlazorStandalone/GridBlazorStandalone.csproj index 8b8aa69c..72db4a64 100644 --- a/GridBlazorStandalone/GridBlazorStandalone.csproj +++ b/GridBlazorStandalone/GridBlazorStandalone.csproj @@ -2,7 +2,7 @@ net6.0 - 3.2.2 + 3.2.3 true diff --git a/GridBlazorStandalone/Pages/ButtonCrud.razor b/GridBlazorStandalone/Pages/ButtonCrud.razor index 0994a3dc..30413534 100644 --- a/GridBlazorStandalone/Pages/ButtonCrud.razor +++ b/GridBlazorStandalone/Pages/ButtonCrud.razor @@ -38,7 +38,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -108,12 +108,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorStandalone/Pages/Crud.razor b/GridBlazorStandalone/Pages/Crud.razor index bd5f42c8..8b646558 100644 --- a/GridBlazorStandalone/Pages/Crud.razor +++ b/GridBlazorStandalone/Pages/Crud.razor @@ -40,7 +40,7 @@ else { private CGrid _grid; private GridComponent _gridComponent; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; private object[] _keys; private GridMode _mode; private Task _task; @@ -107,12 +107,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (!_areEventsLoaded && _gridComponent != null) + if (!_afterRenderExecuted && _gridComponent != null) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorStandalone/Pages/NestedCrud.razor b/GridBlazorStandalone/Pages/NestedCrud.razor index f2720fea..e54b84cc 100644 --- a/GridBlazorStandalone/Pages/NestedCrud.razor +++ b/GridBlazorStandalone/Pages/NestedCrud.razor @@ -43,7 +43,7 @@ else private object[] _keys; private GridMode _mode; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -129,12 +129,12 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.BeforeInsert += BeforeInsert; _gridComponent.BeforeUpdate += BeforeUpdate; _gridComponent.BeforeDelete += BeforeDelete; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridBlazorStandalone/Pages/NestedCrudCreateGrid.razor b/GridBlazorStandalone/Pages/NestedCrudCreateGrid.razor index 956fd816..cf8dd901 100644 --- a/GridBlazorStandalone/Pages/NestedCrudCreateGrid.razor +++ b/GridBlazorStandalone/Pages/NestedCrudCreateGrid.razor @@ -41,7 +41,7 @@ else private GridComponent _gridComponent; private OrderDetailMemoryService _orderDetailMemoryService; private Task _task; - private bool _areEventsLoaded = false; + private bool _afterRenderExecuted = false; [Parameter] public string OrderId { get; set; } @@ -97,10 +97,10 @@ else protected override void OnAfterRender(bool firstRender) { - if (_gridComponent != null && !_areEventsLoaded) + if (_gridComponent != null && !_afterRenderExecuted) { _gridComponent.AfterInsert += AfterInsert; - _areEventsLoaded = true; + _afterRenderExecuted = true; } } diff --git a/GridCore/GridBase.cs b/GridCore/GridBase.cs index 803c17ee..6ef93c1b 100644 --- a/GridCore/GridBase.cs +++ b/GridCore/GridBase.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace GridCore { @@ -15,9 +16,9 @@ public abstract class GridBase //processors process items after adds to main collection (sorting and paging) private readonly List> _processors = new List>(); private IGridItemsProcessor _totalsprocessor; - protected IEnumerable AfterItems; //items after processors protected IQueryable BeforeItems; //items before processors - + protected IEnumerable AfterItems; //items after processors + protected Func, Task>> ToListAsync; private int _itemsCount = -1; // total items count on collection private bool _itemsPreProcessed; //is preprocessors launched? @@ -97,6 +98,11 @@ public string GetRowCssClasses(object item) #endregion protected void PrepareItemsToDisplay() + { + PrepareItemsToDisplayAsync().Wait(); + } + + protected async Task PrepareItemsToDisplayAsync(Func, Task>> toListAsync = null) { if (!_itemsProcessed) { @@ -109,7 +115,10 @@ protected void PrepareItemsToDisplay() else itemsToProcess = processor.Process(itemsToProcess); } - AfterItems = itemsToProcess.ToList(); //select from db (in EF case) + if (toListAsync == null) + AfterItems = itemsToProcess.ToList(); + else + AfterItems = await toListAsync(itemsToProcess); } } diff --git a/GridCore/GridCore.csproj b/GridCore/GridCore.csproj index 758f05ec..f374e2b9 100644 --- a/GridCore/GridCore.csproj +++ b/GridCore/GridCore.csproj @@ -7,7 +7,7 @@ False GridCore GridCore - 5.2.2 + 5.2.3 GridCore Grid core component Grid core component diff --git a/GridCore/ISGrid.cs b/GridCore/ISGrid.cs index a5025464..00efbee8 100644 --- a/GridCore/ISGrid.cs +++ b/GridCore/ISGrid.cs @@ -5,6 +5,8 @@ using Microsoft.Extensions.Primitives; using System; using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace GridCore { @@ -14,6 +16,9 @@ public interface ISGrid : ISGrid, IGrid void SetRowCssClassesContraint(Func contraint); IEnumerable GetItemsToDisplay(); + Task> GetItemsToDisplayAsync(Func, Task>> toListAsync); + + void SetToListAsyncFunc(Func, Task>> toListAsync); } public interface ISGrid : IGrid, IGridOptions @@ -50,10 +55,16 @@ public interface ISGrid : IGrid, IGridOptions void AutoGenerateColumns(); + Task> GetItemsToDisplayAsync(); + /// - /// Get column values to display + /// Displaying grid items count /// + Task GetDisplayingItemsCountAsync(); + /// + /// Get column values to display + /// IList GetValuesToDisplay(string columnName, IEnumerable items); } } \ No newline at end of file diff --git a/GridCore/SGridCore.cs b/GridCore/SGridCore.cs index 14412ca9..d6a7ac1e 100644 --- a/GridCore/SGridCore.cs +++ b/GridCore/SGridCore.cs @@ -19,6 +19,7 @@ using System.Linq; using System.Reflection; using System.Text.Json; +using System.Threading.Tasks; namespace GridCore { @@ -172,6 +173,37 @@ public IEnumerable ItemsToDisplay { get { return (IEnumerable)GetItemsToDisplay(); } } + public virtual IEnumerable GetItemsToDisplay() + { + PrepareItemsToDisplay(); + return AfterItems; + } + + /// + /// Methods returns items that will need to be displayed + /// + public virtual void SetToListAsyncFunc(Func, Task>> toListAsync) + { + ToListAsync = toListAsync; + } + + /// + /// Methods returns items that will need to be displayed + /// + public virtual async Task> GetItemsToDisplayAsync(Func, Task>> toListAsync) + { + SetToListAsyncFunc(toListAsync); + return (IEnumerable)await GetItemsToDisplayAsync(); + } + + /// + /// Methods returns items that will need to be displayed + /// + public virtual async Task> GetItemsToDisplayAsync() + { + await PrepareItemsToDisplayAsync(ToListAsync); + return (IEnumerable)AfterItems; + } /// /// Provides query, using by the grid @@ -194,6 +226,17 @@ public virtual int DisplayingItemsCount } } + /// + /// Count of current displaying items + /// + public virtual async Task GetDisplayingItemsCountAsync() + { + if (_displayingItemsCount >= 0) + return _displayingItemsCount; + _displayingItemsCount = (await GetItemsToDisplayAsync()).Count(); + return _displayingItemsCount; + } + /// /// Enable or disable paging for the grid /// @@ -341,15 +384,6 @@ protected internal void ApplyGridSettings() } } - /// - /// Methods returns items that will need to be displayed - /// - public virtual IEnumerable GetItemsToDisplay() - { - PrepareItemsToDisplay(); - return AfterItems; - } - /// /// Generates columns for all properties of the model /// diff --git a/GridCore/Server/GridCoreServer.cs b/GridCore/Server/GridCoreServer.cs index 0adc5e5e..eafd3496 100644 --- a/GridCore/Server/GridCoreServer.cs +++ b/GridCore/Server/GridCoreServer.cs @@ -8,7 +8,9 @@ using Microsoft.Extensions.Primitives; using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; +using System.Threading.Tasks; namespace GridCore.Server @@ -310,6 +312,12 @@ public IGridServer SetRemoveDiacritics(string methodName) return this; } + public IGridServer SetToListAsyncFunc(Func, Task>> toListAsync) + { + _source.SetToListAsyncFunc(toListAsync); + return this; + } + /// /// Items, displaying in the grid view /// @@ -323,6 +331,14 @@ public ItemsDTO ItemsToDisplay } } + public async Task> GetItemsToDisplayAsync(Func, Task>> toListAsync) + { + var items = await _source.GetItemsToDisplayAsync(toListAsync); + var totals = _source.GetTotals(); + return new ItemsDTO(items, totals, new PagerDTO(_source.EnablePaging, _source.Pager.PageSize, + _source.Pager.CurrentPage, _source.ItemsCount)); + } + /// /// Grid object /// diff --git a/GridCore/Server/IGridServer.cs b/GridCore/Server/IGridServer.cs index 536243ee..b7ea5c68 100644 --- a/GridCore/Server/IGridServer.cs +++ b/GridCore/Server/IGridServer.cs @@ -1,7 +1,9 @@ using GridShared; using GridShared.Utility; using System; -using System.Reflection; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; namespace GridCore.Server { @@ -192,11 +194,15 @@ public interface IGridServer /// IGridServer SetRemoveDiacritics(string methodName); + IGridServer SetToListAsyncFunc(Func, Task>> toListAsync); + /// /// Items, displaying in the grid view /// ItemsDTO ItemsToDisplay { get; } + Task> GetItemsToDisplayAsync(Func, Task>> toListAsync); + /// /// Grid object /// diff --git a/GridMvc.Demo/BlazorComponents/OrdersComponent.razor b/GridMvc.Demo/BlazorComponents/OrdersComponent.razor index f6d21d2c..6fa67c48 100644 --- a/GridMvc.Demo/BlazorComponents/OrdersComponent.razor +++ b/GridMvc.Demo/BlazorComponents/OrdersComponent.razor @@ -118,7 +118,7 @@ else c.Add(o => o.OrderDetails.Count).Titled("Details").SetCrudHidden(true); }; - var client = new GridClient(q => orderService.GetOrdersGridRows(orderColumns, q), + var client = new GridClient(q => orderService.GetOrdersGridRowsAsync(orderColumns, q), query, false, "ordersGrid", orderColumns, locale) .SetRowCssClasses(item => item.Customer.IsVip ? "success" : string.Empty) .Sortable() diff --git a/GridMvc.Demo/Controllers/HomeController.cs b/GridMvc.Demo/Controllers/HomeController.cs index 223a4abf..65caf282 100644 --- a/GridMvc.Demo/Controllers/HomeController.cs +++ b/GridMvc.Demo/Controllers/HomeController.cs @@ -142,7 +142,8 @@ public ActionResult Index(string gridState = "") .SetStriped(true) .ChangePageSize(true) .WithGridItemsCount() - .SetRemoveDiacritics("RemoveDiacritics"); + .SetRemoveDiacritics("RemoveDiacritics") + .SetToListAsyncFunc(async x => await x.ToListAsync()); return View(server.Grid); } @@ -601,7 +602,8 @@ public ActionResult Images() .SetStriped(true) .ChangePageSize(true) .WithGridItemsCount() - .SetRemoveDiacritics("RemoveDiacritics"); + .SetRemoveDiacritics("RemoveDiacritics") + .SetToListAsyncFunc(async x => await x.ToListAsync()); return View(server.Grid); } diff --git a/GridMvc.Demo/GridMvc.Demo.csproj b/GridMvc.Demo/GridMvc.Demo.csproj index 61640a74..ed74e3dc 100644 --- a/GridMvc.Demo/GridMvc.Demo.csproj +++ b/GridMvc.Demo/GridMvc.Demo.csproj @@ -5,7 +5,7 @@ InProcess 3.1 $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; - 5.2.2 + 5.2.3 diff --git a/GridMvc.Demo/Pages/GridPage.cshtml.cs b/GridMvc.Demo/Pages/GridPage.cshtml.cs index 0793d50d..78b5b987 100644 --- a/GridMvc.Demo/Pages/GridPage.cshtml.cs +++ b/GridMvc.Demo/Pages/GridPage.cshtml.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.EntityFrameworkCore; using System; using System.Linq; @@ -133,7 +134,8 @@ public IActionResult OnGet(string gridState = "") .ChangePageSize(true) .WithGridItemsCount() .SetTableLayout(TableLayout.Fixed, "1000px", "400px") - .SetRemoveDiacritics("RemoveDiacritics"); + .SetRemoveDiacritics("RemoveDiacritics") + .SetToListAsyncFunc(async x => await x.ToListAsync()); Grid = server.Grid; diff --git a/GridMvc.Demo/Services/OrderService.cs b/GridMvc.Demo/Services/OrderService.cs index 92b45d74..79503aa1 100644 --- a/GridMvc.Demo/Services/OrderService.cs +++ b/GridMvc.Demo/Services/OrderService.cs @@ -19,7 +19,7 @@ public OrderService(DbContextOptions options) _options = options; } - public ItemsDTO GetOrdersGridRows(Action> columns, + public async Task> GetOrdersGridRowsAsync(Action> columns, QueryDictionary query) { using (var context = new NorthwindDbContext(_options)) @@ -36,7 +36,7 @@ public ItemsDTO GetOrdersGridRows(Action> co .SetRemoveDiacritics("RemoveDiacritics"); // return items to displays - var items = server.ItemsToDisplay; + var items = await server.GetItemsToDisplayAsync(async x => await x.ToListAsync()); return items; } } @@ -86,6 +86,6 @@ public async Task Delete(params object[] keys) public interface IOrderService : ICrudDataService { - ItemsDTO GetOrdersGridRows(Action> columns, QueryDictionary query); + Task> GetOrdersGridRowsAsync(Action> columns, QueryDictionary query); } } diff --git a/GridMvc/GridMvc.csproj b/GridMvc/GridMvc.csproj index ebfe3db3..27e5a2ae 100644 --- a/GridMvc/GridMvc.csproj +++ b/GridMvc/GridMvc.csproj @@ -8,7 +8,7 @@ False GridMvc GridMvcCore - 5.2.2 + 5.2.3 GridMvc ASP.NET MVC Grid component ASP.NET MVC Grid component diff --git a/GridMvc/Views/Shared/_GridBody.cshtml b/GridMvc/Views/Shared/_GridBody.cshtml index 0058aba2..0bb1dd26 100644 --- a/GridMvc/Views/Shared/_GridBody.cshtml +++ b/GridMvc/Views/Shared/_GridBody.cshtml @@ -14,7 +14,7 @@ || firstColumn.IsMaxEnabled || firstColumn.IsMinEnabled); } -@if (Model.DisplayingItemsCount == 0) +@if (await Model.GetDisplayingItemsCountAsync() == 0) { @if (hasSubGrid) @@ -34,12 +34,14 @@ else { @if (Model.GroupingEnabled) { + var items = await Model.GetItemsToDisplayAsync(); @await Html.PartialAsync("_GridGroupRows", new Tuple>, bool, bool, IEnumerable, string> - (Model, new List>(), hasSubGrid, requiredTotalsColumn, Model.ItemsToDisplay, "0")) + (Model, new List>(), hasSubGrid, requiredTotalsColumn, items, "0")) } else { - foreach (object item in Model.ItemsToDisplay) + var items = await Model.GetItemsToDisplayAsync(); + foreach (object item in items) { @if (hasSubGrid)