This is a migrated thread and some comments may be shown as answers.

[Solved] Reset Grid Page

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matthew
Top achievements
Rank 1
Matthew asked on 06 Nov 2009, 10:04 PM
I want to reset the grid pager to page 1.

I have a grid that is populated by selecting a value from a dropdown list. When the user selects a new value from the dropdown and submits the form I want to discard the page number and go back to page 1. Otherwise if the user is viewing page 7 of one set of results and selects a more restrictive option from the dropdown with less results then the grid comes back empty.

Here is my view code.
<div> 
      <% using (Html.BeginForm("Index", "Dispute", FormMethod.Post, new { name = "searchtimespan" })) { %> 
        See more: <%= Html.DropDownList("timespan", Model.DisputeCreationSpan)%> &nbsp;  
        <%= Html.Button("search", "Search", HtmlButtonType.Submit)%> 
      <% } %> 
</div> 

    <% Html.Telerik().Grid<USP_Dispute_SearchResult>(Model.Disputes)  
        .Name("disputesgrid").PrefixUrlParameters(false)  
         .Columns(columns => 
         {  
           columns.Add(d => d.DisputeID).Width(50);  
           columns.Add(d => d.TerminalID).Width(50);  
           columns.Add(d => d.ResponseDueDate).Width(50);  
           columns.Add(d => d.CreateDate).Width(50);  
           columns.Add(d => 
           {  
           %> 
             <%= Html.ActionLink("Details", "Details", new { id = d.DisputeID })%> 
           <%  
           }).Title(" ").Width(50).HtmlAttributes(new { align = "center" });  
         })  
         .Sortable(sort => sort.SortMode(GridSortMode.SingleColumn))  
         .Scrollable(scrolling => scrolling.Height("100%"))  
         .Pageable(paging => paging.PageSize(20).Style(GridPagerStyles.NextPreviousAndNumeric))  
         .Render();  
    %> 
 

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 09 Nov 2009, 08:36 AM
Hello Matthew,

The grid should automatically reset to the first page when you post. I tried this in a sample application which you can find attached. Could you please let me know what is different in your case?

All the best,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Matthew
Top achievements
Rank 1
answered on 09 Nov 2009, 04:23 PM
It looks like I had a problem with routing. I had the following route for my view.

routes.MapRoute( 
    "DisputeIndex",                 // Route name 
    "Dispute.mvc/{page}",               // URL with parameters 
    new { controller = "Dispute", action = "Index", page = 1 }  // Parameter defaults 
); 
 

This caused the page number to be passed in the querystring like http://localhost/Dispute.mvc/2 which caused the grid to not reset to the first page when I posted to it again.
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Matthew
Top achievements
Rank 1
Share this question
or