How to get filter in repeat from two inputs

I would like to filter a repeat from two inputs.

  1. Name
  2. 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??

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:

  1. Name Search - Searching by the customers surname
  2. Filter Select - Filter the the status of the order.

So the filter would be:

  1. Value in name - filter database on name (status would have no value)
    or
  2. 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?

@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:

  1. Name
  2. Status (Collected or Cancelled)

That is all I need to achieve.

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 :slight_smile:

1 Like