Reputation: 41
I am trying to pre-filter a kendo grid, and I have a problem. For pre-sorting and pre-grouping I am using first 2 lines, that work great:
grid.DataSource(ds =>
{
var ajaxDsBuilder = ds.Ajax();
// ...
ajaxDsBuilder.Sort(sort => sort.Add(col.Name).Ascending());
ajaxDsBuilder.Group(grp => grp.Add(col.Name, typeof(string)));
// problem at the next line with filter
ajaxDsBuilder.Filter(f=> f.Add(c=>col.Name.ToString()).IsEqualTo("something"));
which is giving me a server error after running.
For pre-filtering I found this :
.Filter(filter => filter.Add(/* your filter rule */))
If I remove the ToString() I get the error: Property with specified name: col.Name cannot be found on type: System.Data.DataRowView
If I try:
ajaxDsBuilder.Filter(f=> f.Add(c=> c.col.Name).IsEqualTo("something"));
I get the error:
An expression tree may not contain a dynamic operation
I have also tried to use dynamic lambda but the same problems appear ...
What am I missing? P.S. I am new to all this, so any help will be highly appreciated.
Upvotes: 2
Views: 759
Reputation: 41
I answered the same question on Telerik forum and I got my answer:
.Filter(filter => filter.AddRange(new [] { new Kendo.Mvc.FilterDescriptor(col.Name, Kendo.Mvc.FilterOperator.IsEqualTo, "TEST") })
In case someone needs this :)
Upvotes: 2