How to create a condition if none of the values in a repeater dataset match a search term

Hi all,
I have a question on how to use multiple conditions on a repeater.

My setup is, that I have a search box and a repeater with some values in it. If I start typing into the search box, the list of options gets shown below the search box and updated based on the typed input. So far so good, I have managed to do that.

What I need now is another case, if none of the items in the repeater dataset matches my search term.

The interaction should be:

  • I type in the name of a product into the search box.
  • The list of options is shown below the search box as long as my term matches any values from the dataset.
  • But if there are no matches available anymore, I want to show a text below the search box which says: “No product found. Click to add it to the list”.
  • If the user clicks that element,
    • the search term should be added to the dataset of the repeater
    • set as the text into the Search box
    • and the textbox below should disappear.

My main problem is to figure out, how to build a condition that would trigger if no matches are found.

I would be really grateful for any advice.
Thanks a lot,
Stefan

Hi!

The issue here is that when a filter removes all rows, the Item Loaded handler does not execute. So you can’t put the condition in there.

One way is this: put the repeater in a dynamic panel that is set to “fit to content.” You can right-click it and choose “Create dynamic panel.” If you already have it in a DP, just set that DP to fit to content.

Then, use the On Resized event handler of the dynamic panel to handle your condition. If the content is filtered out, the height of the DP will be 0 (or a tad larger if you are specifying a border on the repeater). Create a condition in this event handler that tests the height. E.g.:

On Resized (of DP surrounding repeater)
  If (value) [[This.height]] is less than 1 (any value shorter than your row height is fine here)
     -- do what you want to do when there are no results.
1 Like

Awesome, that worked. Thank you very much.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.