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

paging

4 Answers 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 01 Feb 2013, 03:33 PM
if i have this code
@(Html.Kendo().Grid(Model)    
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.emplmark).Groupable(false);
        columns.Bound(p => p.firstname);
        columns.Bound(p => p.lastname);
        columns.Bound(p => p.location);
        columns.Bound(p => p.county);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetWork", "Company"))
    )
)

The source return around 2000 records,but after i press next page(page 2),the data disapear.why?it isn't enough to put Pageable,to work the paging?

4 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 01 Feb 2013, 04:12 PM
Hello Daniel,

I guess you haven't setup your controller currently. See the step-by-step article on how to implement ajax binding:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/ajax-binding

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Daniel
Top achievements
Rank 1
answered on 04 Feb 2013, 08:38 AM
i supose you are refering to the using of ToDataSourceResult() in controller,which i haven't did,just return a source of data in json.Now i change the code with that.
But the problem is that in this example i use classic Entity framework ORM,i want it to map quickly to a real database with a lot of data
so temployees,is a generated class  of type ObjectSet ,and i put this code,
public ActionResult GetEmployees([DataSourceRequest]DataSourceRequest request)
        {
       var list=new AWModel.AWEntities().temployees;
          
            
            DataSourceResult result = list.ToDataSourceResult(request);

          
            return Json(result,JsonRequestBehavior.AllowGet);   
}

and the error is:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property
the ToDataSourceResult doesn't do the paging of datasource?what can i do in this case?

Regards,
Daniel
0
Accepted
Nikolay Rusev
Telerik team
answered on 05 Feb 2013, 08:27 AM
Hello Daniel,

What ToDataSourceResult extension method does is to apply all server operations(sorting/filtering/paging/grouping..etc.) over the data source and format the response returned to client grid object.

In order to implement server paging the response on read request should return paged data collection in Data field and Total field for the total count of items(so the pager can be properly build). ToDataSourceResult does that for you.

Regarding the error you receive here are few possible solutions:
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/troubleshooting#error-during-serialization-or-deserialization-using-the-json-javascriptserializer

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Daniel
Top achievements
Rank 1
answered on 06 Feb 2013, 11:15 AM
thank you for this link,very helpful.

Best Regards,
Daniel
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or