Using global variables set on other pages to filter in a repeater

Hi

I’m trying to filter a repeater based on variables set on other pages. Essentially I have a number of items scattered through various pages where a user could spot one and “tag” it. I’d have a global variable for each possible item (FN1, FN2, FN3 etc) and a mechanism to set it (yes/no). I haven’t actually built that part yet as I’m confident it will work.

On a summarising page I’d have all possible items in a repeater, along with various characteristics of said items, and I would pass in the value of the relevant global variable into a column (“Show”) in the repeater using OnItemLoad then something like this: [[Item.Show.replace(‘FN1’,FN1).replace(‘FN2’,FN2).replace(‘FN3’,FN3).replace(‘FN4’,FN4).replace(‘FN5’,FN5)]] - having previously, for each item, put the text FN1, FN2, FN3 etc. into the Show column of the repeater dataset.

I’d then (in theory) filter in only the items that the user had tagged on the other pages by looking for “Yes” in the Show item/column - [[Item.Show==‘Yes’]]. This is a very simple filter. Now if I type random Yes / No entries manually into the repeater dataset’s relevant column, they both show on the page (which I’ll eventually suppress) and the filter works as intended.

If I pass in the variable values using the statement two paragraphs above, with the GVs “seeded” with Yes / No entries, then the correct value displays on the page, but the filter “doesn’t work” - by this I mean it actually filters everything out, irrespective of the value of the Yes/No that’s showing on the page - and so I end up with a blank page.

If I manually type some Yes/No entries into some rows and use the data pass in statement in others, the filter works on the manually entered rows, but not the passed in rows, yet in all cases the correct entry appears against the item on the screen.

So this is telling me that the filter isn’t recognising “Yes” as “Yes” when the variable is used. I’ve tried 1s and 0s as well, and same thing. So it’s a data type issue I think, but I don’t know what. I also pinched the “replace” statement from another thread so perhaps there’s a better way to do this that I’m unaware of. It’s a bit past my current paygrade with Axure, I’m afraid. I haven’t done this on a page load to auto trigger the filter yet, I’ve just got a simple button on the page to try to get the filter working correctly first, so it’s not buggering up in the other mechanics anywhere.

Any ideas what I’m doing wrong?

Here is an example that might be slightly different, but maybe also accomplishes what you are trying to do.
Replace your column ‘show’ with the checkbox.

If you are just are try to apply specific filters, I would store them in multiple variable. You can the add the filter onLoad if the variable was changed.

Cheers

Thanks for the reply - I’m not sure I’m quite seeing how this would work in my situation - I can sort of see how it’s working, however.

I’ll have, on the page with the repeater, about 40 items, in the end. These items will be able to be found on up to half a dozen other pages, none of which will have all 40, and some items will appear on multiple pages. I can control whether the user has selected a particular item or not via individual global variables, and I can put the values of those variables into the repeater on my summary page, however when I do so, the filter filters any entry populated via a variable out - even though the same string, typed into the repeater manually, interacts correctly with the filter.

Are you suggesting I could use a (hidden) checkbox mechanism and an OnPageLoad command to check boxes against items where the GV= yes? And then filter for checked, or unchecked rows?

I’ll have to play with that and see what I can work out.

Cheers

So, I tried checkboxes. Now I can set the value of a checkbox to ticked or unticked based on data in the repeater, but I cannot set the value of a checkbox based on data I pass into the repeater from a global variable which, ostensibly, has the same data - so if I type “true” into the repeater and use an IF condition on that, it works, but if I pass the string “true” into a repeater row from a global variable I can show that string “true” ON the repeater row but cannot make it check the checkbox using the same IF condition

Essentially it’s the same problem - there’s something I don’t understand about the data being passed into the repeater from the global variable, irrespective of whether it’s “true”, “yes” or “1” - it’s not being evaluated when I attempt the filter in the way I would expect it to be.

I reiterate that I don’t really understand the intricacies of the “javascript-like” Axure query terms I’m using, I’m just picking them up from what other people have said on these forums and seeing if I can make them work, so it’s highly likely I’m implementing them incorrectly, and there’s a simple solution to all this. It must be possible somehow.

Cheers

Hi DavidS,

When you’re using the [[Item.Show.replace…]] in OnItemLoad, are you using the “Update Rows” action? I wasn’t sure exactly what your OnItemLoad case looked like, but I gave it some thought.

I suspect that the problem might be something to do with updating the repeater rows from inside the repeater itself, while the repeater is loading.

Here’s a couple of ways that might work for you:
Option 1: Create an onPageLoad event that updates the repeater rows based on the variable values
Option 2: Use a second, hidden repeater that updates the values of your primary repeater.

Here’s a file with a small example… the first 3 pages are the ones that you can use to set the variable values, then there are two pages with repeaters.

filter_variables.rp (104.0 KB)

Let me know if that’s helpful for you at all.
-Shauna

This is a lot to try to imagine how it works in my head without being able to view any example. Can you provide a bare-minimum example that demonstrates the problem?

Thanks for the replies. I have an example I can post up, and I’ll have a think about Shauna’s options. Alas, not today as I’m at a conference, so I’ll get back to this Friday, I hope. Cheers.

Hi Shauna - I had a look at your example and eventually figured it out - I broke it a few times in understanding it as everything was named the same and I was getting confused as to what was referring to what - significantly when I broke it, it exhibited the exact behaviour my model did - everything filtered out.

I was working from your first option - the one repeater.

Anyway, I’ve gone back to what I was doing and using Update Rows on page load instead of ItemShow.replace I’ve managed to set variables on various other pages, put the value (hidden) into my repeater, then on page load run a filter to filter in just “yes” values.

Set value of DavidS to “Happy Camper”

Thanks a lot for your help. Much appreciated. :slight_smile: