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

Grid Sorting, filtering not working.

6 Answers 681 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 25 Jan 2016, 03:53 PM

 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();

6 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 27 Jan 2016, 03:36 PM

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
0
Arun
Top achievements
Rank 1
answered on 27 Jan 2016, 06:19 PM

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

 Thanks.

0
Arun
Top achievements
Rank 1
answered on 27 Jan 2016, 09:45 PM
Also want to ask if there is any guidelines on how to use grid based on data and other factors. 
0
Boyan Dimitrov
Telerik team
answered on 29 Jan 2016, 03:48 PM

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
0
Arun
Top achievements
Rank 1
answered on 29 Jan 2016, 03:57 PM
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.
0
Boyan Dimitrov
Telerik team
answered on 02 Feb 2016, 02:02 PM

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
Tags
Grid
Asked by
Arun
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Arun
Top achievements
Rank 1
Share this question
or