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

[Solved] ActionResult Paging not working

1 Answer 108 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gaurav
Top achievements
Rank 1
Gaurav asked on 26 Mar 2012, 11:31 AM
Hello,

I am trying to set  .PageTo property for grid, which should set as -

.PageTo((int)ViewData["currentPage"]) to get current page, but the problem is ViewData["currentPage"] has no value.

The problem seems to be that ActionResult Pagin event is not working/Firing

although i have registered it as

.DataBinding(dataBinding => dataBinding.Ajax().OperationMode(

 

GridOperationMode.Client).Select("_Paging", "Target").Delete("_Delete", "Target").Enabled(true)


Any reason why its not working..?
Thanks

1 Answer, 1 is accepted

Sort by
0
Dadv
Top achievements
Rank 1
answered on 30 Mar 2012, 04:13 PM
GridOperationMode.Client => in this mode, server will be call only once

.PageTo((int)ViewData["currentPage"])  => ViewData come from the action how show the grid in your case it is NOT _Paging 


Could you provide the action that call the grid (not the _Paging one)?

you probably need something like this :

public ActionResult Index()
{
ViewBag.CurrentPage = 2;
return View();
}

<%= Html.Telerik().Grid<OrderDto>()
       
.Name("Grid")
       
.Columns(columns =>
       
{
            columns
.Bound(o => o.OrderID).Width(100);
            columns
.Bound(o => o.ContactName).Width(200);
            columns
.Bound(o => o.ShipAddress);
            columns
.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(120);
       
})
       
.DataBinding(dataBinding => dataBinding.Ajax()
               
.OperationMode(GridOperationMode.Client)
               
.Select("_OperationMode", "Grid"))
       
.Pageable()
       
.Sortable()
       
.Scrollable()
       
.Groupable()
       
.Filterable() .Pageable(p=>p.PageTo(ViewBag.CurrentPage)) 
%>


But this will work only one time on the page load.

if you want that the server define the current page, i'm not sure you can in ajax binding because the only data transmit in ajax is the Data source, the Total and the Aggregates.

Tags
General Discussions
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Share this question
or