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

Programmatically clearing radio button filters

3 Answers 555 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sune
Top achievements
Rank 1
Sune asked on 25 Nov 2015, 01:57 PM

Hi

We have a grid with a boolean column that is filtered with "Yes" or "No" radiobuttons.

When clearing a filter programmatically, by e.g. 

$("#grid").data('kendoGrid').dataSource.filter(null)

the filters are cleared as expected but the radio button remains selected on either Yes or No if I open the columns filter.

If I then click the Filter-button without touching the radio buttons nothing happens even though e.g. Yes was selected.

However if I click No and then Yes and then do the Filter, it will do the Yes-filtering.

This only seems like an issue for radiobuttons, for all other types, strings, datetime and checkboxes the values are cleared along with the filter.

 

Can you recommend a fix/workaround?

Thanks, Sune

3 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 26 Nov 2015, 10:04 AM
Hi Sune,

You can use the following approach to achieve this requirement:
Copy Code
$("button").click(function () {
  $("form.k-filter-menu button[type='reset']").trigger("click");
})

Here is a working live sample:
http://dojo.telerik.com/oxIMI/10

Hope this helps. Please give it a try and let me know if it works for you.


Regards,
Eyup
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sune
Top achievements
Rank 1
answered on 26 Nov 2015, 12:42 PM

Hi Eyup,

 

Thanks, it works :)

What I am after is trying to remove a filter for a column that gets hidden.

So I have a specific column in mind and getting the correct Clear/reset button for a specific column is not so easy, it seems the filter is a little form in itself not directly connected to the column of the table.

What I did was add an identifying text to the form, "Is connected" like so in the configuration:

filterable: { messages: { info: 'Is connected:', isTrue: "Yes  ", isFalse: "No" } }

Then I can select the correct Clear button with:

if (column.title == "Connected") 
$("div.k-filter-help-text:contains('Is connected')").parent().find("button[type='reset']").trigger("click");

Not sure how to do this genericly only using the column information, e.g. column.title or colomn.field unless I set the info equal to the column.title of course.

Anyway, maybe my real question is: "What is the best way to remove filters on hidden columns?" :)

 

Best regards,

Sune

0
Eyup
Telerik team
answered on 30 Nov 2015, 09:44 AM
Hi Sune,

Does this approach work for you? If you need further assistance, you can send us some modified dojo sample along with sample screenshots or video demonstrating the desired functionality.

Regards,
Eyup
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Sune
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Sune
Top achievements
Rank 1
Share this question
or