DataGrid paging/filtering/LoadData

Hi,

I have a custom filter which is applied on LoadData. The DataGrid is in pagination mode with 5 items per page. Say I am on page 3, then I apply my custom filter and call grid.Reload(). Then, say, because of the filtering there is now only 1 row but the grid still thinks it's on page 3 and passes me the Skip for page 3. I added some logic to skip to the last page of data if the Skip passed in is beyond that. This works fine but the pager still thinks its on page 3 instead of the last page of the new filtered dataset. Can the grid actually calculate the new skip by itself? Can the pager recognize the new page? I think it would be great if I could pass the new skip back to the LoadData caller via the args.

So the question is how to properly update the page number after filtering if filtering changes the number of pages? Thanks!

Here's my logic for new skip:

            var count = query.Count();
            var pageSkip = args.Skip.Value / args.Top.Value;
            var pageMax = count / args.Top.Value;

            args.Skip = Math.Min(pageSkip, pageMax) * args.Top.Value;

Found a workaround, which probably calls LoadData twice though it would be nice if the grid could do it itself and update the pager to the last page if current page is beyond the new count. thanks!

    async Task MyCustomFilterUpdatedAsync()
    {
        await refGrid.Reload();
        var lastPage = MyModel.MyData.Count / refGrid.PageSize;
        if (refGrid.CurrentPage > lastPage)
        {
            await refGrid.GoToPage(lastPage);
        }
    }

Also, I want to store current page when filter is applied and restore the page when the filter is removed. I added a handler to DataGrid.Filter but inside the handler Grid.CurrentPage is always zero... Any suggestions? thanks!