I would like to filter a repeat from two inputs.
Name
Status
So I would like it to work for either or
code I thought it was is:
dmx-bind:repeat="(v_orders.data.query.where(`c_surname`, inp_filter_name.value, 'fuzzySearch') || v_orders.data.query.where(`oi_status`, select1.value, 'fuzzySearch'))"
However this only filters the first one (inp_filter.name.value)
Does anyone have any ideas??
TomD
May 19, 2021, 9:40am
2
I don’t think it’s possible to do it this way, but I could be wrong. However, you could use a ternary operator to make it work, eg:
inp_filter_name.value? 'base repeat on this value' : 'base repeat on other value'
(but you would probably want to use another ternary operator for the second result).
Do you want to be able to filter by any of these two inputs or filter using them both at the same time?
want to filter by any of these inputs @Teodor
So what is the expected result when the user fills in both?
When I say any of them @Teodor it will be used as the following:
Name Search - Searching by the customers surname
Filter Select - Filter the the status of the order.
So the filter would be:
Value in name - filter database on name (status would have no value)
or
Value in select - filter database on status (name would have no value)
Teodor
May 19, 2021, 10:04am
7
gunnery:
Value in name - filter database on name (status would have no value)
or
Value in select - filter database on status (name would have no value)
You say filter database - then why not filter the database query instead of the repeat on the page?
Antony
May 19, 2021, 10:04am
8
@gunnery , I do this a lot and I do all the selection in my server action’s database query.
So I pass in all the parameters, and then use the “conditional conditions” as shown below!
1 Like
On this page, the database filter is for orders that have been collected or cancelled.
With the results I just simply would like to be able to either like to filter the repeat region by either:
Name
Status (Collected or Cancelled)
That is all I need to achieve.
Teodor
May 19, 2021, 10:15am
10
Maybe try this then:
dmx-bind:repeat="v_orders.data.query.where(`c_surname`, inp_filter_name.value, 'fuzzySearch').where(`oi_status`, select1.value, 'fuzzySearch')"
Maybe you don’t need fuzzysearch for the select, if that’s a select menu. You can try just == if these are fixed values there you are selecting from.
1 Like
awesome that was what I needed. Cheers @Teodor
1 Like