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

How do you pass client-side filters to the server?

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 27 Jun 2019, 04:27 PM

     I've got a bunch of methods client-side that build up a list of all the filters to apply to a grid. However, I'm told it is possible to pass this list over to the server in order to have better control over the filters? In my case, I am trying to create a filter that looks like this:

`(cond || cond || cond) && cond`

I've noticed that Kendo seems to only support cases where it is `cond || cond` or `cond && cond`. Unless there is a way to make the above condition work, how can I pass my filters to the server and the `DataSourceRequest` in order to have that further control?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 01 Jul 2019, 10:47 AM
Hi Ryan,

You could create the `(cond || cond || cond) && cond` filter as follows:

var filter = {
  logic:'and',
  filters:[
    {field:'...', operator:'...', value: '...'},
    {
      logic:'or', filters:
      [
        {field:'...', operator:'...', value: '...'},
        {field:'...', operator:'...', value: '...'},
        {field:'...', operator:'...', value: '...'}
      ]
    }
  ]
}

Furthermore, you can submit this filter to the server using the dataSource.filter method.

e.g.

grid.dataSource.filter(filter)

Have in mind that server operations should be enabled (by default they are enabled with Ajax binding), otherwise the grid will filter the data on the client and omit submitting the request to the server.

I hope this answers your questions.


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or