Hide empty repeater rows

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Ian, Dave, jcoulson, Jon, Wai

Segi
Ebase User
Posts: 585
Joined: Mon Dec 09, 2013 6:37 pm

Hide empty repeater rows

#1

Postby Segi » Mon Jun 16, 2014 3:19 pm

I have a repeater that gets unique order numbers. Each repeater row displays a table for each order number.

I want to hide all repeater rows where the child table has no rows.

I have searched the documentation but cannot find anything that tells you the FPL syntax for table.rowcount. I've tried adding the filter expression MYTABLE.ROWCOUNT > 0 but this crashes the application.

What is the right way to do this ?
0 x

Jon
Moderator
Moderator
Posts: 1273
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue Jun 17, 2014 7:28 am

The way I have done this in the past is to add an additional column, say ROW_COUNT, to the parent table (orders) - don't display this column to the user. If possible, populate this from the database with the count of child record rows (is your table data coming from a database?) when you load the rest of the data. Then loop through the table, check for 0 records and hide/show the repeater row control as appropriate.

Regards
Jon
0 x

fronsky
Ebase User
Posts: 54
Joined: Thu Mar 08, 2018 2:52 pm

Re: Hide empty repeater rows

#3

Postby fronsky » Wed Jul 10, 2019 4:24 pm

Is there also a more elegant solution possible? Can you explain how you solved this Segi?
0 x

Segi
Ebase User
Posts: 585
Joined: Mon Dec 09, 2013 6:37 pm

Re: Hide empty repeater rows

#4

Postby Segi » Thu Jul 11, 2019 6:34 pm

Here's how I did it:

Users_2 is the parent table and SIGNATURETYPES is the child table

The logic behind this, if you're interested, is for each user, display the signature types that they are authorized for. If there aren't any signatures that the user is authorized for, hide the user row entirely.

Code: Select all

var allUsers=tables.USERS_2;
     var allUserRows=allUsers.getRows();

     var allSignatureTypes=tables.SIGNATURETYPES;
     while (allUserRows.next()) {
          var parentRow=allSignatureTypes.findRow(allSignatureTypes.REALNAME,allUsers.REALNAME.value);

          // No SignatureTypes rows
          if ( parentRow == -1 ) {
               tables.USERS_2.REALNAME.fieldControl.parentControl.setHidden(true);
          } else {
     	         tables.USERS_2.REALNAME.fieldControl.parentControl.setHidden(false);
          }
     }
Last edited by Segi on Fri Jul 12, 2019 3:03 pm, edited 1 time in total.
0 x

fronsky
Ebase User
Posts: 54
Joined: Thu Mar 08, 2018 2:52 pm

Re: Hide empty repeater rows

#5

Postby fronsky » Fri Jul 12, 2019 7:56 am

Thank you Segi! Looks good. I will give it a try.
I was not aware that's possible to control the display of controls upfront for all records.

Update: Works. Thanks
0 x


Who is online

Users browsing this forum: No registered users and 1 guest