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

Dynamic filtering of Grid

3 Answers 915 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Moshe Hayun
Top achievements
Rank 1
Moshe Hayun asked on 16 Oct 2017, 07:58 AM

Hello,



In my application (Dynamics 365), I added many Kendo Grid (using TypeScript and C# WCF as Backend). I'd like to implement a general dynamic functionnality of server filtering (because I use paging on read request, so it must be filtered on server side).

 

Firstly, I'd like to know how to implement exactly a server filtering of data source. In my backend function, I have the DataSourceRequest parameter, I added serverFiltering:true to my DataSource definition in TS. But I think that I miss something here, particularly the filter parameters on the data source (JSON format right?). Something like this:

   "take":10,
   "skip":0,
   "page":1,
   "pageSize":10,
   "filter":{ 
      "filters":[ 
         
            "field":"Column1",
            "operator":"eq",
            "value":"val1"
         },
         
            "field":"Column1",
            "operator":"eq",
            "value":"val2"
         },
         
            "logic":"or",
            "filters":[ 
               
                  "field":"Column2",
                  "operator":"eq",
                  "value":5
               },
               
                  "field":"Column2",
                  "operator":"eq",
                  "value":1
               }
            ]
         }
      ],
      "logic":"and"
   },
   "group":[ 
 
   ]
}

 

How it can be done?Should I check if filtering is applied every column of my grid and what is the filter? And I guess that once the filter passed, I will be able to read it on the parameter passed to the backend function (request.Filters).

 

I'm newbie on Kendo, so I'll appreciate a detailed answer with full example if possible.

 

Thank you.

Moshe.

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 18 Oct 2017, 05:57 AM
Hello, Moshe,

When the serverFiltering is applied to the Grid, it will automatically add the filter parameters as part of the request. The format of the parameters can be observed in the documentation:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-serverFiltering

When using a WCF as a backend, there are some specifics which has to be taken into account. I can suggest checking the following forum thread, with examples and code snippets demonstrating how to use DataSourceRequest with WCF:

https://www.telerik.com/forums/kendo-mvc-and-wcf

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Moshe Hayun
Top achievements
Rank 1
answered on 18 Oct 2017, 08:51 AM

Hello Stefan,

 

Thank you for your answer. But I found a solution. I simply forgot (or ignored) to add type:"aspnetmvc-ajax" to my DataSource (and not to my transport read!)

 

export const ACTIVITIES_GRID_DATASOURCE = new kendo.data.DataSource({
    serverPaging: true,
    serverFiltering: true,
    filter: [],
    type: "aspnetmvc-ajax",
    transport: {
        read: {
            url: `${crudServiceBaseUrl}/ActivitiesList`,
            dataType: "jsonp",
            data: function () {
                var toolbar: kendo.ui.ToolBar = $("#menu").data("kendoToolBar");
                var selected: any = (toolbar && toolbar.getSelectedFromGroup("radio") || "");
                return { viewType: (selected && selected.attr("id") || "") };
            }
        },
    },

 

Solution found here: https://www.telerik.com/forums/datasourcerequest-filters-and-sorts-fields-null-here-is-the-solution

 

Have a nice day.

 

Regards,

Moshe

0
Moshe Hayun
Top achievements
Rank 1
answered on 18 Oct 2017, 08:53 AM
And this is why my request.Filters received on the backend were null.
Tags
Grid
Asked by
Moshe Hayun
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Moshe Hayun
Top achievements
Rank 1
Share this question
or