Hi there. New to retool so am hoping to find some answers to my questions. I'm wondering whether there's a way, using this table filter I can make multiple and or or statements. I've found that when I select a statement in my first condition, it cannot be changed when it comes to adding a second condition. I know you can use either statements in an sql query e.g WHERE (condition1 AND condition2) OR (condition3 AND condition4); but is this something I can do using this filter to allow a more user friendly approach for my app user?
Hi @ArT1! In the "Add" dropdown, you can select "Add filter group" to add a nested clause, so the filter could look something like this:
You can also achieve these filters by running a script on an event handler to set the filter stack -- the example below matches the filter output I've shown in the screenshot!
table1.setFilterStack({
filters: [
{
filters: [
{ columnId: "id", operator: "<=", value: 10 },
{ columnId: "id", operator: ">=", value: 8 },
],
operator: 'and'
},
{
filters: [
{ columnId: "id", operator: "<=", value: 5 },
{ columnId: "id", operator: ">=", value: 3 },
],
operator: 'and'
},
],
operator: "or",
});
You can nest as much as you want following this convention!
You're a star. Thank you so much
2 Likes