Hi,
I had the same question and while searching for an answer, I found this thread.
My grid has a different datasource and has virtual loading.
I have everything working ok but when I go to, for example, the 3rd virtual page and then hit some column to Sort, the request to the server only returns one page, and is the 3rd page, and the grid shows some empty results and then the sorted 3rd page.
You can see this in the "broken sort.PNG"
If you can help me with this I appreciate.
But to fix this behaviour I thought to go to the first page when sorting/filtering, so I end up here.
I added the this.model.pageSettings.currentPage = 1; in the ActionBegin and, in the controller, the DataManager.Skip is == 0, so it returns the first page only., but the scrollbar has a weard behaviour.
It does not go to the start when I hit sort.
In the "first search.PNG" is the grid after the first search. everything ok
In the "before sort.PNG" is the grid in the 3rd page and everything is still ok.
In the "after sort.PNG" you can see the grid, in the 1st page BUT the scroll is in a random(?) position. why? can I force the scroll go to the first record?
My grid in the cshtml:
.Datasource(d => d.URL("/mycontroller/DoVirtualSearch").Adaptor("UrlAdaptor"))
.IsResponsive(true)
.EnableResponsiveRow(false)
.AllowSorting()
.ScrollSettings(s => s.AllowVirtualScrolling().VirtualScrollMode(VirtualScrollMode.Continuous).Height(400))
.SortSettings(sort => sort.SortedColumns(col => col.Field("Date").Direction(SortOrder.Descending).Add()))
.MinWidth(650)
.AllowSelection()
.AllowScrolling(true)
.ClientSideEvents(e => e.ActionBegin("ActionBegin"))
.AllowResizing()
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
And the controller:
public ActionResult DoVirtualSearch(DataManager dm, SearchModel model)
{
List<SearchRecord> list = MyService.Search(model);
DataResult result = new DataResult();
DataOperations operation = new DataOperations();
result.result = list;
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
result.result = operation.PerformSorting(result.result, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
dm.Where.ForEach(f => f.Operator = "contains");
result.result = operation.PerformWhereFilter(result.result, dm.Where, "contains");// dm.Where[0].Operator);
result.count = result.result.Cast<SearchRecord>().Count();
}
else
{
result.count = result.result.Cast<SearchRecord>().Count();
}
if (dm.Skip != 0)
{
result.result = operation.PerformSkip(result.result, dm.Skip);
}
if (dm.Take != 0)
{
result.result = operation.PerformTake(result.result, dm.Take);
}
return Json(result, JsonRequestBehavior.AllowGet);
}
Attachment:
PNGs_2dfb154b.zip