Server side paging and sorting functionality

6 posts, 0 answers
  1. hash
    hash avatar
    6 posts
    Member since:
    Jun 2011

    Posted 14 Feb 2013 Link to this post

    I am trying to achieve serverside paging and sorting with Kendo grid. 

    I have done the following which is working fine, but this is completely in the JavaScript,

    ("#appointmentsGrid").kendoGrid({
            columns: [
                        { field: "MemberFirstName", title: "Member<br/>First Name" },
                        { field: "MemberLastName", title: "Member<br/>Last Name" }                   
                     ],
            dataSource: new kendo.data.DataSource({
            serverPaging: true,
            serverSorting: true,
            transport: {
                read: {
                    url: "/AppointmentScheduling/GetScheduledAppointments",
                    data: additionalData
                }

            },
            pageSize: 10,
            schema: { data: "data", total: "total" }
            }),
            pageable: true,
            sortable : true
        });   

     Can anyone has any idea how to achieve the same functionality through razor View, if so can you please give the controller sample code too.

    Since it is in javaScript, there is no intellisense and hard to find out all the options that i can give it for a column. 
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 18 Feb 2013 Link to this post

    Hi,

    You can find an example implementation of server operations and ASP.NET MVC in this code library.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. hash
    hash avatar
    6 posts
    Member since:
    Jun 2011

    Posted 18 Feb 2013 Link to this post

    Hi Rosen, 

    Thanks for the reply, But the code that you referred me is implementing the KEndo grid in the Javascript style.

    But, i am looking for Razor extensions style. (something like this)

     @(Html.Kendo().Grid<AppointmentsDTO>().Name("ScheduledAppointments")
                    .Columns(columns =>
                        {
                            columns.Bound(o => o.MemberFirstName).Title("Member<br/>First Name");
                        columns.Bound(o => o.MemberLastName).Title("Member<br/> Last Name");
                        columns.Bound(o => o.ClientMemberID).Title("Health Plan ID");
                        columns.Bound(o => o.ProviderID).Title("Provider ID");
                        columns.Bound(o => o.ProviderFirstName).Title("Practitioner<br/> First Name");
                        columns.Bound(o => o.ProviderLastName).Title("Practitioner<br/> Last Name");
                        columns.Bound(o => o.AppointmentDateDisplay).Title("Appointment<br/> Date / Time").Width(125);
                        columns.Bound(o => o.IHAAppointmentID).Hidden(true);
                    })
                    .DataSource(dataSource => dataSource
                    .Ajax()
                    .Read(read =>
                        {
                            read.Action("GetScheduledAppointments", "AppointmentScheduling");
                            read.Data("additionalData");
                        }))
                    .Events(e => e.DataBound("onDataBound"))
                    .Pageable(page => page.Enabled(true).PageSizes(new[] { 20, 30, 50, 100 }))
                    .Sortable()
                    .Scrollable(scroll => scroll.Height(225))
                    .AutoBind(false)
                    )
  4. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 18 Feb 2013 Link to this post

    Hi,

    Information on how to setup the KendoUI for ASP.NET MVC Grid widget for AJAX binding can be found here. Details about custom binding configuration, in case you want to handle the data processing manually, can be found here.

    Also you may find helpful the sample application available within the KendoUI for ASP.NET MVC distribution.

    Regards,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. hash
    hash avatar
    6 posts
    Member since:
    Jun 2011

    Posted 18 Feb 2013 Link to this post

    Hi Rosen, 

    Thanks for the quick reply. I actually referenced the same document when i am trying to achieve this functionality, but the problem i am currently facing is , in the request object the sorts is always coming as null, I examined the request with Developer tools I can see the sorts coming as request parameter. 

    Any idea, why the sorts is always null in the Datasourcerequest object. 

    I am sure the if i send the code, that will help you, but my app is 3 layered app and i definitely can not send the code sample :(. I looked at multiple forum posts on the same issue and i came to know its not just me, but none of them posted a clear answer. 

    Any help is appreciated. 
  6. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 18 Feb 2013 Link to this post

    Hello,

    You should verify that you have correctly configured your project. Make sure the kendo.aspnetmvc.min.js file is included and script files are in the correct order.

    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!
Back to Top