Loading Repeater with Filters


#1

So I have a pre-filled repeater table with 10 items. I’m passing values for those items to global variables and I want to show the results in a table, but filter out items that have 0 entries.

I can either show the results WITH 0 entries and it works (as in, it’s grabbing the variable values correctly)…OR…I can show nothing, which most likely means it’s filtering the 0’s out before it’s grabbing the variables.

I can’t seem to figure it out. I’ve tried a “WAIT” interaction, but that doesn’t seem to work.

This is essentially a cart function where the table represents the checkout cart.

Anyone have examples of how they are doing this?

Cheers.

-g


#2

OK, here is a simplified version.

The top repeater is the out of the box version with an added row. The Filter option is to remove “0” value scores. It works.

The second repeater is one that is driven mostly by global variables. The last row (NonGlobVar) is hard-coded. The remove “0” filter only removes the hard-coded “0”.

So, I guess the question is - how to get the filter to respect the repeater “as is” vs. what is first loaded.

Side note: The button filter will ultimately be moved to a Page or Repeater Load filter - it’s only a button now to try to see what’s happening.

Thanks in advance for the help.

Repeater.rp (97.4 KB)

-g


#3

It turns out the filter IS respecting the repeater “as is”. In the second repeater, you’re not updating the repeater’s data sheet, you are only setting the text value of the “QTY_RepCell” widget, and not updating the data sheet. Filters work on the data sheet–the column values. In the second repeater, the first three rows still have a blank value for the “QTY” column.

In this updated file I’ve made a few additional repeater examples that I hope can help demonstrate this.
Repeater filtering with 0.rp (141.8 KB)

  • I duplicated your Page 1 to Page 2 and added a few more repeater examples.

  • I added a new button beside the second repeater, Table 2, that applies a filter to show only rows with a QTY value of ‘8’. It doesn’t work, even though the Reclosure row shows a value of ‘8’ --again, this is because the repeater’s data sheet has never been updated, so that row still has a blank value in the QTY column.

  • In Table 3, I attempted to replace the Set Text actions with Edit Row Data in the repeater’s Item Loaded event, so the data sheet would get updated and set to the corresponding global variable value.

    • I did not expect this to work, and indeed it does not. Editing row data as the repeater is loading would be a dangerous move–it could likely result in a never-ending loop. It appears the prototype and/or browser code detects this and blocks the actions.
    • (Just in case, I also tried to set a row’s value to a hard number instead of a global variable, and it did not work either.)
  • In Table 4, I cut the Edit Row Data actions from Item Loaded and pasted them to a new button, “Update All Rows”

    • Clicking this new button works. Values are properly set in the repeater’s data sheet, and filters work (of course, even if they’ve been applied prior to clicking “Update All Rows”).
    • I then added a Loaded event to the repeater (this gets called once, immediately after all the rows in the repeater are initially loaded) that fires the Click or Tap of the “Update All Rows” button, thus properly updating the repeater’s data sheet with the initial values of the global variables.
    • I also duplicated the Transformer Count buttons, adding an Edit Row Data action so the repeater can reflect the incremental change to the global variable.
  • In Table 5, I cut the Edit Row Data actions from “Update All Rows” and put them directly in the repeater’s Loaded event. (The separate button in Table 4 example was mostly for demonstration purpose.)


#4

So much to learn… sigh

Thank you kindly for taking time to help.

In the interim, waiting for an answer, I went with a different approach that seems to be working. Not sure which one is better at this point.

I used a Page Load “add rows” approach, hard-coding the Materials (column 1) into each row and using the Global Variable to get the respective value of the QTY (column 2).

Is this a “better” approach than my original request?

I think I’ll be able to use what you’ve done here when it comes time to “EDIT” the cart. I’ve ALWAYS struggled with dealing with existing/updating repeater data. Version 10 makes it much easier than 8, but I still don’t fully get it. :smiley:


#5

I’d say mostly it is just a little different. As long as it works, that’s great. Depends on how and if you plan to extend and/or reuse this. The first approach, which kind of integrates global variables into the repeater’s load, could make that repeater more reusable across pages, without needing a Page Loaded event to make it work. Your second approach (sounds like it) uses a more traditional repeater structure, so could be more reusable across projects/prototypes, and wouldn’t necessarily require specific global variables in order to work.

Yeah, repeaters are quite the concept… it can take a lot to learn how to use them, but I think it is time well spent.


#6

Appreciate your help. For now I have a good, working model (with MUCH thanks to you).

I always have to simplify and strip IP to upload, so I’ll avoid it unless needed.

Cheers.

Joe


closed #7

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