We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Reset page to 1 for a data grid

Thread ID:

Created:

Updated:

Platform:

Replies:

118942 Apr 27,2015 07:25 AM UTC Dec 7,2017 03:47 PM UTC ASP.NET MVC 3
loading
Tags: Grid
William Wong
Asked On April 27, 2015 07:25 AM UTC

Hi I am using the MVC Grid control with data binding. I find that the page number won't be reset after changing of the sort item, I would like to reset the page index to the very first page (i.e. page 1) after sorting/filtering and I wonder what is the proper way to implement this feature? BTW, I think that the client side event ActionBegin is not being fired if the grid has invoked EnablePersistence inside the view.

Alan Sangeeth S [Syncfusion]
Replied On April 29, 2015 03:48 AM UTC

Hi William,

Thanks for using Syncfusion Products.

Query 1: “After filtering/sorting, Grid must move to first move page”
We are glad to let you know that we have achieved your using “ActionBegin” Grid event in which when the request from Grid is Filtering or sorting we have updated the current page to 1. Please refer the following code snippets.

(Html.EJ().Grid<EJGrid.Models.EditableOrder>("Grid")

...

ClientSideEvents(eve => eve.ActionBegin("beginHandler"))

)


<script>

function beginHandler(args) {

if(args.requestType =="sorting" || args.requestType == "filtering")

this.model.pageSettings.currentPage = 1;

}

</script>



For your convenience we have created a sample and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/forum/118942/EJGrid1182064056.zip

Query 2: “ActioBegin event not triggers when “EnablePersistence” is enabled”

We regret to let you know that we are unable to reproduce the issue in our end. We have created the above provided sample with “EnablePersistence” enabled in the sample and it is working fine.

Could you please let us know more information about the issue such as the scenario, Grid code snippets or if possible, reproduce the issue in the above sample and send us back so that we could provide you a response as early as possible?

Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S

Bruno Figueiredo
Replied On December 4, 2017 04:50 PM UTC

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

Venkatesh Ayothi Raman [Syncfusion]
Replied On December 7, 2017 03:47 PM UTC

Hi Bruno, 
 
Thanks for the update. 
 
We are able to reproduce the reported issue at our end and we have considered this “Sorting is not working while using virtual scroll mode as continuous” as bug and fix for this issue will be included in our upcoming Volume 4,2017 release which is expected to be rolled out in the month of December,2017. 
 
Until we suggest to you use Virtual scroll mode as Normal for your requirement. 
 
Regards, 
Venkatesh Ayothiraman. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;