Nested Repeaters

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: Jon, Steve, Ian, Dave

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

Nested Repeaters

#1

Postby Segi » Wed Dec 07, 2016 9:52 pm

I developed a form with Nested repeaters. It displays company information which is organized in a 4 level hierarchy and use 3 repeaters

Its organized like this:

Code: Select all

Level 1 (Company owner)
     Image control with the owners' photo
     Display only Text field with the owners' name

     Level 2 (Nested Repeater)
          Image control with the persons' photo
          Display only Text field with an employees' name
          
          Level 3 (Nested Repeater)
               Image control with the persons' photo
               Display only Text field with an employees' name
               
               Level 4 (Nested Repeater)
                    Image control with the persons' photo
                    Display only Text field with an employees' name
I set up the filter expressions for each repeater. In the before page event, I call fetch table on the DB resource used by the repeaters and the names are correctly displayed at the level that they are supposed to be at.

I also have logic in the before page event to loop through each repeater and dynamically load the user image.

For Level 2, I do

Code: Select all

allRows=tables.LEVEL2;
rows=allRows.getRows();

while (rows.next()) {
     controls.USERIMAGE2.setImageURL(userImagePath);
}
For Level 3, I do

Code: Select all

allRows=tables.LEVEL3;
rows=allRows.getRows();

while (rows.next()) {
     var parentRow=tables.LEVEL2.findRow(tables.LEVEL2.Realname,allRows.ReportsTo.value);

     if (parentRow != -1) {
          tables.LEVEL2.setCurrentRow(parentRow);
     }

     controls.USERIMAGE3.setImageURL(userImagePath);
}
For Level 4, I do

Code: Select all

allRows=tables.LEVEL4;
rows=allRows.getRows();

while (rows.next()) {
     var parentRow=tables.LEVEL3.findRow(tables.LEVEL3.Realname,allRows.ReportsTo.value);

     if (parentRow != -1) {
          tables.LEVEL3.setCurrentRow(parentRow);
     }

     controls.USERIMAGE4.setImageURL(userImagePath);
}
The user image loads perfectly for levels 1-3 but I am running into an issue with level 4, where the user image does not get set. I displayed a warning message right after the line var parentRow=tables.LEVEL3.findRow(tables.LEVEL3.Realname,allRows.ReportsTo.value); which displays the value of the variable parentRow which is correct but the user image does not get set. I can't figure out why its not working.

I noticed that doing controls.USERIMAGE4.setHidden(true) does not seem to hide the image control which makes me think that I am not working on the correct repeater row.
0 x

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

#2

Postby Jon » Thu Dec 08, 2016 9:48 am

In general, in order to set the state of a control within a nested repeater structure the current row of ALL parent tables must be correctly set i.e. in your example to hide something in level4, the current row of level1, 2 and 3 must also be set.

From what you've written I can't tell if you have a genuine nested 4-level structure. Is it possible that your structure is actually:

Level1
  • Level2A
    Level2B
    Level2C
If it is, the controls structure should match this.
0 x

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

#3

Postby Segi » Thu Dec 08, 2016 10:36 am

Jon

That is correct. My naming convention is different but pretty much I have

Level 1 (not a repeater)
Level 2 (repeater of rows which are children of level 1)
Level 3 (repeater of rows which are children of level 2)
Level 4 (repeater of rows which are children of level 3)

In level 2, I don't set parent row because it doesn't have a parent repeater (works fine)
In level 3, I set the parent row to the level 2 parent (works fine)
I'm level 4, i set the parent row to the level 3 parent (doesn't work)

I did try to set level 2 then 3 parent in level 4 but that didnt make a difference.
0 x

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

#4

Postby Segi » Thu Dec 08, 2016 6:01 pm

Jon,

I added another DB column in the level 4 DB resource (which already has the name of the level 3 parent) to get the level 3' parent and used that to set the parent of the parent row and now it works fine
0 x

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

#5

Postby Jon » Thu Dec 08, 2016 6:14 pm

This sounds like the best way to treat all repeaters - include all parent key fields in each table, but only display the columns you want to display.
0 x

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

#6

Postby Segi » Thu Dec 08, 2016 6:44 pm

Jon

Right. I had to link the Level 4 repeater to the level 2 repeater indirectly through the DB resource.

Now that thats working I have 1 more question.

Would the same parent or grandparent row logic need to be used to show or hide all children of a repeater.

I added an image control to levels 2 & 3 which toggles between an image of a plus and minus sign (Minus is the default) when clicked. If the user clicks on the image and the loaded image is the minus I want to hide all children. If its plus, I want to show all of that repeater rows' children

so say the current row is a level 2 row and the user clicks on the minus, I want to hide all level 3 and level 4 children of that level 2 row. same goes with Level 3 where I want to toggle between showing and hiding all level 4 children of the current level 3 row.

So basically what I'm asking is how do you hide children of a repeater row ?
0 x

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

#7

Postby Jon » Fri Dec 09, 2016 9:25 am

how do you hide children of a repeater row?
As always, the current row of ALL parent repeater tables must be set.

Put all the child controls in a container - say a Panel Control (in your case this might be another Repeater) then hide that container.
0 x


Who is online

Users browsing this forum: No registered users and 65 guests