Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Pre-filter in dynamic kendo grid

$
0
0

I have worked based on : .Filter(filter => filter.Add(/* your filter rule */)) , that I found in here.

 My code is : 

  var grid =
        Html.Kendo().Grid<dynamic>().Name(Model.Current.Id).HtmlAttributes(new
        {

           // lot of stuff

       }

 grid.DataSource(ds =>
    {
        var ajaxDsBuilder = ds.Ajax();
        ajaxDsBuilder.Model(model => model.Id("ID")).Events(ev => ev.Error("gridOnError")).ServerOperation(Model.Current.LazyLoading);

// mode code

      var cols = Model.Current.Columns.ToList();

           foreach (var col in cols)
              {​

                 ajaxDsBuilder.Sort(sort => sort.Add(col.Name).Ascending()); // this works perfect for pre-sorting     ( col.Name = the column name ) 

                 ajaxDsBuilder.Group(grp => grp.Add(col.Name, typeof(string))); // this the same works great for pre-grouping

 

 ​but when I try this:

          ajaxDsBuilder.Filter(f => f.Add(c=> c.col.Name).IsEqualTo("TEST")); ​

I get : Error309 An expression tree may not contain a dynamic operation 

 

if I try:  ajaxDsBuilder.Filter(f => f.Add(c=> col.Name.ToString()).IsEqualTo("TEST")); ​// I am overriding ToString() to give me the name of column

I get : Internal server error

 

 if I try:  ajaxDsBuilder.Filter(f => f.Add(c=> col.Name).IsEqualTo("TEST")); 
I get : Property with specified name: col.Name cannot be found on type: System.Data.DataRowView

 

I have also worked with lambda expressions, but I have pretty much the same errors. 

My grid has to be dynamic, so I can't change that.

Any help?


Viewing all articles
Browse latest Browse all 94857

Trending Articles