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

[Solved] Paging: passing whole model into ajax databinding

1 Answer 47 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.
Trancedified
Top achievements
Rank 1
Trancedified asked on 16 May 2012, 12:18 AM
Hello,

I have a grid that gets data from a WCF Service. When I'm trying to do paging, I'd like to pass the whole model back into the _Paging ActionResult so that I can post to the WCF Service again and bring back the data. Is this possible? How else can I get the values I need to pass to the WCF Service? As for now the objRequest parameter inside the _Paging method is null.

Here's my view:
Html.Telerik().Grid(Model.objGetEventSchedule_Response.EventSchedules.ToList())
.Name("Grid")
.Pageable()
.Sortable()
.Columns(columns =>
{
    columns.Bound(o => o.MasterScheduleID);
    columns.Bound(o => o.EventScheduleID);
    columns.Bound(o => o.EventDatetime);
    columns.Bound(o => o.EventType);
    columns.Bound(o => o.CustomerID);
    columns.Bound(o => o.CREATEDDATE);
    columns.Bound(o => o.LAST_UPDATE_TS);
    columns.Bound(o => o.UPDATE_BY);
})       
.DataBinding(dataBinding => dataBinding.Ajax().Select("_Paging", "GetEventScheduleRequest"))
.Pageable(paging => paging.Style(pagerStyles).Position(position).PageTo(currentPage))
.Render();


Here's my controller:
[GridAction]
public ActionResult _Paging(CombinedGetEventSchedule objRequest)
{
 
    var objList = new List<CombinedGetEventSchedule>();     
    objList.Add(GetData(objRequest));
 
    IEnumerable<CombinedGetEventSchedule> objCombined;
    objCombined = objList;
 
    return View(new GridModel<CombinedGetEventSchedule>
    {
 
        Data = objCombined
    });
      
}

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 18 May 2012, 03:12 PM
Hello Chris,

To send additional values to the server when your Grid is rebinding ( paging/sorting/filter performed)  you should use the OnDataBinding event - there is an example in the documentation which shows how to do it.
I hope this helps.

Kind regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Trancedified
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or