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

Kendo Grid help with paging

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajiv
Top achievements
Rank 1
Rajiv asked on 12 Feb 2013, 06:00 PM
Hello Everyone,
This is the first time I am posting to Kendo Forums, so forgive me if I step over any posting rules. 
I am very new to Kendo UI and MVC 4. So far, I have been able to get the data to display on the grid on my web page.
But I am having issues with the data binding to the grid. The first time the page displays, it correctly displays the first 10 records, but when I click on "Go to Next page", the web page throws error.

I understand that it has to do with data binding to the grid. My question is, how do I go about this? i.e. Do I need to add the code to the controller or the view? and if so, where should I add the new method and how would it look like? I am posting my code below for your review. Please feel free to make any suggestions. Thank you for reading.

@model IEnumerable<MVC4Trial.Models.vwCallDetail>
@{
    ViewBag.Title = "Index";
}

<h2>Call Detail View</h2>

@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
    {
        columns.Bound(p => p.CCCID).Width(50).Title("CCCID");
        columns.Bound(p => p.Mp3_Url).Width(50).Title("MP3 URL");
        columns.Bound(p => p.Target_Number).Width(50).Title("Target Number");
        columns.Bound(p => p.Duration).Width(50);
        columns.Bound(p => p.Index).Width(50);
        columns.Bound(p => p.LocalTime).Width(50);
        columns.Bound(p => p.Site_Name___Address).Width(50).Title("Site Address");
        columns.Bound(p => p.Ad_Source_Name).Width(50).Title("Ad Source Name");
        columns.Bound(p => p.Tracking_Number).Width(50).Title("Tracking Number");
        columns.Bound(p => p.Caller_Number).Width(50).Title("Caller");
        columns.Bound(p => p.Available_Feature).Width(50).Title("Features");
        
       
    })
    .Groupable()
    .Pageable(page => page.Enabled(true).PageSizes(new Int32[] {10, 20, 30, 40}))
    .Sortable(sorting => sorting.SortMode(Kendo.Mvc.UI.GridSortMode.SingleColumn))
    .Scrollable()
    .Filterable()
    .DataSource(datasource => datasource
        .Ajax()
        .Read(read => read.Action("vwCallDetail", "Grid"))
        .PageSize(10)
        .ServerOperation(true)
        .PageSize(10)
        )
    .Resizable(resize =>resize.Columns(true))
    .Reorderable(reordering => reordering.Columns(true))
    ) 

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 14 Feb 2013, 09:17 AM
Hi Rajiv,

Indeed, you should implement an Action method which to return the required data. Please refer to this help article on how to configure the Kendo Grid for ASP.NET MVC for AJAX binding.

Also you may find helpful the sample demo app, which is bundled with the KendoUI for ASP.NET MVC distribution.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Rajiv
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or