Filtering Table According Selected Dropdown Options

hi people,

i have a query to bring some data. i added 3 dropdown to filter the table. i used Search term to filter but i can not combine 3 filter together. for instance 1st filter is category filter, 2nd filter is seller, 3rd filter is booking number.

i used && operator to use 3 filter together, but it did not work too

image

HI there @halil,

Have you considered using the default filters functionality? A post here that it is helpful How to use setFilterStack to filter values in an array - #2 by mckenna

Best,
Miguel

1 Like

Hi Miguel,

many thanks. Let me check.

best regards.

hi again,

i used normal filter, and nested filter but when i run 3rd filter, i am getting following error.

and i want to see only related dropdown options. for example i have 100 booking in different categories. when i select adventure, i want to see only adventure category's booking in dropdown menu, not all booking. in order to do that i am using table.data as data source for dropdowns.

Hi there @halil,

I see what you're doing there.

Firstly, you can use the default filters section within your table set up and reference your select values there.

Within your select2 data source, you can add a filter.

{{ select1.value ? yourdatasource.data.filter(x => x.category === select1.value) : yourdatasource.data }}

The terniary will take in account situations when nothing is selected in your category dropdown

Here are some useful posts:

How to use setFilterStack to filter values in an array - #4 by mckenna (in case you are using multitags)

2 Likes

hi Miguel,

many thanks for your help, i really appreciate that. instead tag, i used string, it works.

i also want to share the way, in case someone needs.

1st, with sql query i get the data, and convert the tag into strings.
2nd, i need to filter the data based on 3 different column variables, so i added 3 select/dropdown menu

  • As data source in selects, i used following block of code. because i need to see related values, based on each filter
{{ select5.value ? table4.data.filter(x => x.kategorieName === select5.value) :table4.data }}
  • for the last filter, following one is used.
{{ (select4.value ? table4.data.filter(x => x.schedulerLoggerBookingFixedReason === select4.value) :table4.data) && (select5.value ? table4.data.filter(x => x.kategorieName === select5.value) :table4.data) }} 

3rd, those selects are added as Default filters.

2 Likes