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

Grid - sorting and filtering

2 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lorenzo
Top achievements
Rank 2
Lorenzo asked on 14 Aug 2012, 09:08 AM
Hello
when use Ajax binding sorting and filtering parameter where not correctly passed on server handler:
I usethe following code in my MVC view:
<%:
 
Html.Kendo().Grid<Totalcom.XBase.Biz.Base.Models.Elements.Element>()
.Name("Grid").Columns(columns =>
{
     
    columns.Bound(p => p.IsActive).Title("Attivo");
    columns.Bound(p => p.Name);
    columns.Bound(p => p.Key);
     
})
.DataSource(dataSource => dataSource
        .Ajax() // Specify that the data source is of ajax type
        .Model( model =>
            {
            model.Id (x => x.Key);
            model.Field(x => x.IsActive);
            model.Field(x => x.Name);
            model.Field(x => x.Key);
            })
          .Sort(sort => sort
              .Add(x => x.Name)) 
        .Read(read => read.Action("GetChildren", "Documents", new { Area = "CMS", Id = Model.Key, ApplicationKey = Html.GetSessionInfo().ApplicationKey}))  
         
        )
.Sortable()
.Pageable()%>

and when I try to sort the get query is the following:

/CMS/Documents/GetChildren/xx?&take=10&skip=0&page=1&pageSize=10&sort%5B0%5D%5Bfield%5D=Name&sort%5B0%5D%5Bdir%5D=desc

it seems that the sort parameter is not correctly encoded. on my controller the code is the following :

public ActionResult GetChildren([DataSourceRequest]DataSourceRequest request)
      {
         ...
          DataSourceResult result = children.ToDataSourceResult(request);
          return Json(result, JsonRequestBehavior.AllowGet);
      }


request.Sort and request.filter are NULL
Any suggestion?

2 Answers, 1 is accepted

Sort by
0
Iliana Nikolova
Telerik team
answered on 14 Aug 2012, 11:24 AM
Hi Lorenzo,

The most likely reason for the problem is that kendo.aspnetmvc.min.js is not included or is included before kendo.web.min.js - please make sure the order is correct. Also, I believe you may find this troubleshooting section from our online documentation useful.  

I hope this information helps.
 
Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Lorenzo
Top achievements
Rank 2
answered on 14 Aug 2012, 01:58 PM
Thanks.
i was including only "kendo.all.js"
Tags
Grid
Asked by
Lorenzo
Top achievements
Rank 2
Answers by
Iliana Nikolova
Telerik team
Lorenzo
Top achievements
Rank 2
Share this question
or