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

Set Multi Filter Programmatically

7 Answers 941 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 2
Iron
Brian asked on 11 Dec 2017, 08:42 PM

Hi,

Is it possible to programmatically set a column's filter whose "multi" flag is set to true on grid load?

The code I have here:

1.$("#Grid").data("kendoGrid").dataSource.filter({
2.    field: "Person",
3.    operator: "eq",
4.    value: "Brian"
5.});

... doesn't seem to filter properly or show the checkbox for the selected filter.  It filters out everything and no checkboxes in the filter menu are selected.

Thanks!

7 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Dec 2017, 10:52 AM
Hello, Brian,

I made an example using the provided approach to set a filter programmatically and the filter was applied as expected on my end to the "ProductName" column:

http://dojo.telerik.com/oruXO

In case I missed an important part of the scenario, please modify the Dojo and I will gladly assist further.

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
Brian
Top achievements
Rank 2
Iron
answered on 13 Dec 2017, 01:21 PM

Hi Stefan,

This works -- however, I'm using the MVC controls with the associated HtmlHelpers.  Does your scenario work with the MVC grid as well?

Thanks!

0
Accepted
Stefan
Telerik team
answered on 14 Dec 2017, 08:58 AM
Hello, Brian,

The same approach can be used in the MVC Grid.

I made an example and the result is the same.

I attached the example for reference.

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
Brian
Top achievements
Rank 2
Iron
answered on 14 Dec 2017, 01:45 PM

Hi Stefan,

That was perfect.  I see what I did wrong now.  I used the column header name instead of the field name to filter on.

Problem solved.  Thanks so much!

0
Shishir
Top achievements
Rank 1
answered on 05 Jun 2019, 10:13 PM

This does not works if set the dataSource.filter with multiple filters like this.

$("#grid").data("kendoGrid").dataSource.filter(
            {
                "filters": [{
                    "field": "ShipCity",
                    "operator": "ne",
                    "value": "ShipCity 2"
                    },
                {
                    "field": "ShipName",
                    "operator": "ne",
                    "value": "ShipName 2"
                }],
                "logic": "and"
            }
        );

 

Is there a different way of setting multiple filters?

0
Tsvetomir
Telerik team
answered on 07 Jun 2019, 02:21 PM
Hi Shishir,

I have investigated the provided code snippets and it appears that they are set-up as expected. However, the project that has been provided by my colleague in the post below uses an outdated version of the Kendo UI suite. Can you try using the same approach with the latest version and see if the issue is still present?

For your convenience, I am attaching the modified project to my response. Give it a try and let me know how it works out for you.


Kind regards,
Tsvetomir
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.
0
Shishir
Top achievements
Rank 1
answered on 23 Jul 2019, 09:23 PM

All good.

Thanks

Tags
Grid
Asked by
Brian
Top achievements
Rank 2
Iron
Answers by
Stefan
Telerik team
Brian
Top achievements
Rank 2
Iron
Shishir
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or