Grid Sorting, filtering not working.

7 posts, 0 answers
  1. Arun
    Arun avatar
    15 posts
    Member since:
    Oct 2014

    Posted 25 Jan Link to this post

     Below is code where I am trying to create master detail grids where data is fed through list of objects. When I run it I do get master detail grids, but when I try to do sorting, filtering, paging, I lose my page and I am sent back to home page. And If I use alternate DataSource code as below I get error "Cannot use only server templates in Ajax or WebService binding mode. Please specify a client template as well."

    Please advice. Thanks. 

    My model is something like this

     public partial class Invoice
        {
            public int InvoiceNumber{ get; set; }

    ..

    ..

       public List<IvDetail> IvDetails { set; get; }
    }   

     

    And here is view code.

     

    @model IEnumerable<Portal.Models.Invoice>

    @{ Html.Kendo().Grid(Model)
        .Name("InvoiceGrid")
                .Pageable()
                .Columns(columns =>
                {
                    columns.Bound(p => p.InvoiceNumber).Filterable(true).Title("Invoice Number");
                    columns.Bound(p => p.InvoiceDate).Title("Invoice Date");
                    columns.Bound(p => p.InvoiceTotal).Title("Invoice Total");
                    columns.Bound(p => p.Balance).Title("Balance");
                })
                .Filterable()
                .Sortable()
                .Navigatable()
                .DataSource(dataSource => dataSource.Server().PageSize(15))

                // this gives error "Cannot use only server templates in Ajax or WebService binding mode. Please specify a client template as well."
                //.DataSource(datasource => datasource
                //    .Ajax()
                //    .PageSize(15)
                //    .ServerOperation(false)
                //    .Sort(sort =>
                //    {
                //        sort.Add(p => p.InvoiceNumber);
                //    })
                // )
                .DetailTemplate(
                    @<text>           
                        @(Html.Kendo().Grid(item.IvDetails)
                                .Name("IvDetails_" + item.InvoiceNumber)
                                .Columns(columns =>
                                {
                                    columns.Bound(o => o.ItemNumber);
                                    columns.Bound(o => o.PartNumber);
                                    columns.Bound(o => o.Description);
                                })
                                .DataSource(dataSource => dataSource.Server().PageSize(15))                    
                                .Pageable()
                                .Sortable()
                                .Filterable()
                        )
                    </text>
        )
        .Sortable() 
        .Render();

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 27 Jan Link to this post

    Hello Arun,

     

    Indeed if you want to use an ajax bound grid client templates should be used instead of server templates. Please refer to the Client Detail Template step-by-step tutorial that shows how to define and use client templates with the ajax bound grid. 

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Arun
    Arun avatar
    15 posts
    Member since:
    Oct 2014

    Posted 27 Jan in reply to Boyan Dimitrov Link to this post

    So the way my code is above sorting is not possible? Also will your suggested link work without entity framework?

     Thanks.

  5. Arun
    Arun avatar
    15 posts
    Member since:
    Oct 2014

    Posted 27 Jan Link to this post

    Also want to ask if there is any guidelines on how to use grid based on data and other factors. 
  6. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 29 Jan Link to this post

    Hello Arun,

     

    I guess the problem you are facing with server bound hierarchy grid and sort-able functionality is that the grid is posted and re-rendered on the server. The main disadvantage in this case is that the expanded rows are persisted between the requests and they are always collapsed. 

     

    Could you please clarify whether using server bound grid is required or ajax bound grid will work for your scenario? 

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Arun
    Arun avatar
    15 posts
    Member since:
    Oct 2014

    Posted 29 Jan in reply to Boyan Dimitrov Link to this post

    To be honest I am new to Kendo MVC Grids and I just want to do the right way. If Ajax bound grid is the right way then I will do that. Also I changed my code based on your suggest link and everything is working now. It would be very helpful if you point me to link that has guidelines for using grids. Thank You again.
  8. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 02 Feb Link to this post

    Hello Arun,

     

    In order to get started with the Kendo UI Grid for ASP.NET MVC I would suggest to review the following resources: 

     

       1. Telerik UI for ASP.NET MVC Fundamentals article. 

       2. Kendo UI Grid for ASP.NET MVC overview article. 

       3. Ajax Editing tutorial. 

       4. Client Detail template tutorial. 

     

     

    Regards,
    Boyan Dimitrov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET MVC is VS 2017 Ready