How to filter a Repeater-Field that contains specific String?


#1

Hi,
how can I filter a Repeater-Field that contains specific String?

Example:
In an Input-Fiel I start writing a text, and while writing it should start to filter a Repeater by that value.

Let’s say the Repeater-Field “location” contains:
New York
New Orleans
Norway

When I enter “N” in the Input-Field it should show all. When I enter “New”, then it should show only the first two. When I enter “York” it should show only the first one.
It should also ignore upper- or lowercase.

I have tried something like that:
[[ item.location.toLowerCase.contains(this.text.toLowerCase) ]]

But it does not work.

Does anybody know what possibilities Axure has to solve that task?

Kind regards
Alain


Disturbing browser elements when using a text field in my drop down list design
#2

Here is a forum thread with a solution:

Applying this expression to a Repeater, where you have a column labeled, “City” would look like:
[[ Item.City.indexOf(LVAR1) >= 0 ]]

  • Where LVAR1 is your filter or “search” string.
  • The .indexOf() function will return a number which is the index of the first character in the search string. If the search string is not found in the target string, it returns -1, thus the rule would fail.
  • Note this works for any string (portion) regardless of position. So in your example above, filtering for “n” would result in all three items shown; filtering for “or” would also result in all three items shown.
  • (numbers in logical expressions don’t need quotes; works either way with 0 or ‘0’)

Applying this to a Text Field for “live dynamic filtering”, you can use this widget’s Text Changed or Key Up event (fired every time a keyboard key is pressed and released)–and using “case insensitive” logic–the filter rule would be:
[[ Item.City.toLowerCase().indexOf(This.text.toLowerCase()) >= 0 ]]

Here is a little demo:
Live Dynamic Filter.rp (55.3 KB)


#3

Thanks alot! :slight_smile:
It’s solved.


closed #4

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