Filter - Dropdown Menu - Uncheck all by default

Tags: #<Tag:0x00007efc72fac240> #<Tag:0x00007efc72fac088>

Hi,

There was a post back in 2018 about the dropdown menu on filters when loading to have all the checkboxes unchecked rather than checked by default:

This is what I was looking to do, but also i am trying to amend this so that if you selected an item to filter on then when you go back to it then this item to be checked rather than it running the clear all function that was shown in your example on the above link.

Do you have any examples or can point me in the right direction?

Many thanks

Steve

Hi @sgamble

Unfortunately, there have been no changes in the subject since then. However, the trick with unchecking all checkboxes still works in the latest version https://jsfiddle.net/y93r4njd/1/ (v13.1.0). We did not alter the demo to work with a selected checkbox, but I can imagine that adding a condition to run the hook or not would work. Maybe something like this https://jsfiddle.net/y93r4njd/2/

Aleksandra!

Thats great - thanks for your quick feedback on this. The demo seems to do what I was looking to do, so I will have a go at implementing this and get back to you if I need further help.

Thank you and have a great day!

Steve

1 Like

You’re more than welcome, @sgamble :slight_smile:

Aleksandra,

So its nearly working and the issue I now have is currently showing up on your simple demo too.

I have filtered by 1 item and that works, i go back to it and this one is selected still, which is what I wanted. If I deselect it and then select all by clicking the Select All. I get a console error of Uncaught TypeError: Cannot read properties of undefined (reading ‘column’). and the drowndown menu doesnt close?

Regards

Steve

Ah yes, I see. It’s cause the selectAll removes the condition stack. I added the condition to the afterFilter https://jsfiddle.net/nj36sexa/

ps. as this is a custom solution I am not sure if it will work 100% for all the cases.