Server repeat on paged query

I have a server side repeat after a paged query and it runs another custom query to determine the validity of each of the records:
image

All is working as expected, but I need the IsValid member of the repeat to be in the paged.data array (output of the first query). Instead, it is output as it’s own separate array:

Is there a way to move the repeat array values into the paged.data array? Or, at least be able to reference it on the client for each row in a table?

I’m still learning my self but I believe what you’d do here is on the repeat output all the fields you are using then you will be able to access them in the repeat just like your validation field

Or you could join the tables if you select your first query then add the second table

If I output all the fields, I get duplicate data. Once for the paged query and again for the repeat. I can turn off the output for the paged query, but then I loose all my paged properties and the paging doesn’t work.

I actually got the values to show in the table by using this expression: sc_punches.data.validate_repeat[$index].IsValid
But that seems like sort of a hack and the sorting won’t work.

I might have to join the tables, but then I’ll have to write a completely custom query because it’s checking the every record for overlaps based on fairly complex criteria. But maybe that would be worth it, then the sorting would work as well.

Did you change the bind after outputting on the repeat if you currently have it set to the paged query you would need the expression on the app side on the table section column etc etc to point to the repeat

Yes I changed the binding to the repeat and it actually does work. However, like I said before, I’m getting the data twice because I have to leave the output turned on for the paged query and that seems inefficient. Seems like there should be a way to combine the two arrays into one and discard the other.

I think I could do it with a view and then just use that view for my paged query. I might have a look at that idea, unless someone has any more ideas how to make this work.
Thanks!

The better option is to create a view in the DB and just use that for the paged query.

Here's another thing you can try. Disable the output on paged query. Instead, create another variable below paged query, and set the "page" part of the paged query as its value, and enable output.
Then, set the repeat to output all the fields from paged query.

This way, you can use this set value to setup pagination on the page, and use the repeat step output to bind your table or other repeat structure.

1 Like

I got a view to work, but I’ve lost a lot of performance because it’s checking each record against every other record in the table and there is over 10k records and growing… :slight_smile: It’s not too bad for just paging one page at a time, but if I jump all the way to the last page, it can take a number of seconds - sometimes 20 or more. My original repeat was doing something similar, but only for a single page ‘set’ at a time, so was pretty quick.

Maybe I can figure out a way to speed up the view, otherwise, I’ll have a look at @sid’s idea of the variable below the paged query. Not sure I follow completely, but will have a look.