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

GridModel.Total doesn't seem to work

1 Answer 53 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.
oliwa
Top achievements
Rank 1
oliwa asked on 17 Dec 2011, 07:01 AM
I am trying to set up paging in my grid so that when a user navigates to a page only the data for that specific page is retrieved from the database and pushed down to the client.  Here is some sample code to give you an idea.

[GridAction]
public ActionResult GetGridData()
{
    var list = new List<UserViewModel>();
 
    for (int i = 0; i < 100; i++)
    {
        list.Add(new UserViewModel { Id = i});
    }
 
    var pagingList = list.Skip(20).Take(5).ToList();
 
    return View(new GridModel { Data = pagingList, Total = list.Count});
}

The JSON sent down to the client is this...

{"data":[{"Id":24},{"Id":23},{"Id":22},{"Id":21},{"Id":20}],"total":5}

So obviously the correct JSON is getting serialized but for some reason the Total value is not getting serialized as it was set.

I have attached a solution demonstrating the issue.  There should be more than 1 page.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 19 Dec 2011, 10:31 AM
Hello Oliwa,

In order to instruct the grid to on perform all paging/sorting etc. operation on the data that has been set custom binding should be used. Otherwise the grid will attempt to page the data that is set inside Data property.

Greetings,
Nikolay Rusev
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
oliwa
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or