Hello,
I want to integrate grid persistence in my projects, I have a list of products that have thousands of records. I have server side pagination and client side filtration. When I filter the products by SKU or by other columns, it filters only first page's record and when I go to the other pages, it displays no records found because filter's records are not available on those pages. So first, I should have to integrate the filtration on server-side to filter the correct data for each and all the pages but I have lots of columns as well and would not be able to find the demo or source code to integrate the filter on server side or either I have to integrate the pagination on client side but I would have to fetch all records which can cause a performance issue.
Can you please suggest what would be a good practice to bind the thousands of records with pagination and filtration on all columns and maintain the grid persistence as well?
Thanks
Imrankhan
Hi Joseph,
Yes, We want to perform both filtering and paging on server side and want to retain grids settings.
Please also note that we have a column reorder and resize feature as well so if we change columns order or resize the columns that grid setting should also retain on page refresh.
Thanks
Imrankhan
|
[fetchdata.component.ts]
ngOnInit(): void {
this.data = new DataManager({
url: "/Home/UrlDatasource",
adaptor: new UrlAdaptor,
});
}
[HomeController.cs]
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
IEnumerable DataSource = OrdersDetails.GetAllRecords();
DataOperations operation = new DataOperations();
if (dm.Search != null && dm.Search.Count > 0)
{
DataSource = operation.PerformSearching(DataSource, dm.Search); //Search
}
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
DataSource = operation.PerformSorting(DataSource, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Cast<OrdersDetails>().Count();
IEnumerable groupedData = null;
if (dm.Skip != 0)
{
DataSource = operation.PerformSkip(DataSource, dm.Skip); // Paging
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = groupedData == null ? DataSource : groupedData, count = count }) : Json(DataSource);
}
|