No Results Page for a Repeater

I have a repeater that I am using as a search results display and I have 29 possible results. I am having an issue where, if your search returns no results, the count still sets to 29. I would like the counter set to 0 and to show a “No Results” message. I am attaching my prototype below. Can anyone see what I am doing wrong?

Thanks!

MessageSearch_Repeater_No_Results.rp (511.2 KB)

Hi!

The thing to understand here is that OnItemLoad is triggered for each row in the repeater, so it does not get triggered at all if filter returns no rows, and OnItemLoad is where you are setting the count.

(As an aside, this filtering model is more complicated than it needs to be. The filter depends on the values of multiple global variables, when you could be using local variables in the filter. For example, your code sets a global variable when a checkbox is checked so your filter knows its checked state, but you could just as easily examine the selected state of this checkbox directly in the filter using a local variable. You can ignore this for now, but your code would be much easier to debug that way.)

The thing you are doing that you should absolutely avoid doing is forcing the repeater to re-evaluate its filter by reloading the page. (E.g., on clicking the Submit button.) Instead, force the repeater to re-evaluate its filter by executing a do-nothing command on a repeater. (E.g., set the current page of the repeater to 1, or execute a Delete rows command that deletes no rows, like “Delete rows in repeater where [[false]]”. A filter, once created, remains in effect until it is deleted.

So instead of reloading the page to force the filter to re-evaluate, you can do the following:

On Click (of submit button)
  Set text on Count to 0
  Set items per page of (repeater) to 1 

The first command sets Count to 0 in case OnItemLoad never executes.
The second command forces the repeater to re-evaluate its filter.

Hi @josephxbrick - Thank you for your response. I am sure the OnItemLoad was my problem. Unfortunately, I got pulled into another project so I need to wait a few days to try out your solution.

The example file I sent was a stripped down version of what I am building so I am setting global variables on another page and bringing them into the repeater so I know my file was a little confusing.

In retrospect, it would have been better for me to start my experience with Axure on a less complicated project!

Thanks again!

Ah, that makes about the global variables.

So basically there are a couple things you can do when calculating values in OnItemLoad to handle the zero-rows case (when OnItemLoad won’t run).

  • Preset all displayed values to what they would be were there zero rows, and then force the repeater to redraw as mentioned (which will show new values if rows do exist)

  • Encase just the repeater in a fit-to-content dynamic panel, and test to see if the height of this panel is 0, which it will be when there are no rows. E.g:

    If (value) [[LVAR_repeaterPanel.height]] is equal to 0
1 Like

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