Nesting Repeaters?

32 views
Skip to first unread message

Pete Thornbury

unread,
Jan 5, 2018, 10:03:01 PM1/5/18
to structr
Is it possible to nest a second repeater into a top level repeater so that for each <TR> for example, if that row has a relationship with multiple entries, I could make another table within that cell (aka <td> tag) that would then list a couple attributes of each object linked through a relationship.

I assume I make another table and tr inside that td and then in query / data binding tab of that inner table's tr, would I put something in the REST query that references the current outer tr's data entry?  Or would I put something in one of the other tabs? (Cypher, XPath, Function?)

Sorry for what might be a total noob question.  I love the idea of Structr, but I am a complete novice when it comes to any type of code / script.  I know old school HTML and am trying to fumble my way through some basic personal CMS stuff with Structr because I can finally make the data structure I want thanks to neo4j.

Kai Schwaiger

unread,
Jan 6, 2018, 6:34:21 AM1/6/18
to str...@googlegroups.com
Hi Pete,

this is certainly not a noob question and we appreciate you asking!

You assumed correctly that it does work and that the easiest way to do it is using another tab - the “Function” tab.

I’ll explain using a simple example:


1. Schema


2. Page

I built a simple page where a table is rendered for every company and each employee is rendered as a row in that table.


3. Repeater Configuration

The table repeater is configured as a REST query “Company” and the dataKey is set to “c”.
So inside the repeater we can use the variable “c” to access the current Company object.



The row repeater uses the Function Query type of repeater. I configured the query as “c.employees” (see the above screenshot for “Remote Attributes” of Company)
Because a Company has a collection of employees we can use this attribute in a repeater element.
We set the dataKey to “e” so inside the repeater we can access the current Employee object via the “e” variable.



Hope that helps!

Cheers,
Kai

Kai Schwaiger · Structr GmbH
Hanauer Landstr. 291a · 60314 Frankfurt, Germany

--
You received this message because you are subscribed to the Google Groups "structr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structr+u...@googlegroups.com.
To post to this group, send email to str...@googlegroups.com.
Visit this group at https://groups.google.com/group/structr.
To view this discussion on the web, visit https://groups.google.com/d/msgid/structr/e8a517d4-b207-462e-8650-48410cad5995%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kai Schwaiger

unread,
Jan 6, 2018, 6:44:32 AM1/6/18
to str...@googlegroups.com
Oh, and I forgot: You can also do this via REST but this way is much more elegant in my opinion.

The inner REST repeater Query would read "Employee?employer=${c.id}” (assuming the remote attribute on the “Employee” type was set to “employer”)

Cheers,
Kai


Kai Schwaiger · Structr GmbH
Hanauer Landstr. 291a · 60314 Frankfurt, Germany
On 6. Jan 2018, at 12:34:16, Kai Schwaiger <kai.sc...@structr.com> wrote:

Hi Pete,

this is certainly not a noob question and we appreciate you asking!

You assumed correctly that it does work and that the easiest way to do it is using another tab - the “Function” tab.

I’ll explain using a simple example:


1. Schema
<schema.png>
<company_remote_attributes.png>


2. Page

I built a simple page where a table is rendered for every company and each employee is rendered as a row in that table.

<page.png>

3. Repeater Configuration

The table repeater is configured as a REST query “Company” and the dataKey is set to “c”.
So inside the repeater we can use the variable “c” to access the current Company object.

<table_repeater.png>


The row repeater uses the Function Query type of repeater. I configured the query as “c.employees” (see the above screenshot for “Remote Attributes” of Company)
Because a Company has a collection of employees we can use this attribute in a repeater element.
We set the dataKey to “e” so inside the repeater we can access the current Employee object via the “e” variable.

<row_repeater.png>


Hope that helps!

Cheers,
Kai

Kai Schwaiger · Structr GmbH
Hanauer Landstr. 291a · 60314 Frankfurt, Germany

On 6. Jan 2018, at 04:03:00, Pete Thornbury <pe...@peteonline.net> wrote:

Is it possible to nest a second repeater into a top level repeater so that for each <TR> for example, if that row has a relationship with multiple entries, I could make another table within that cell (aka <td> tag) that would then list a couple attributes of each object linked through a relationship.

I assume I make another table and tr inside that td and then in query / data binding tab of that inner table's tr, would I put something in the REST query that references the current outer tr's data entry?  Or would I put something in one of the other tabs? (Cypher, XPath, Function?)

Sorry for what might be a total noob question.  I love the idea of Structr, but I am a complete novice when it comes to any type of code / script.  I know old school HTML and am trying to fumble my way through some basic personal CMS stuff with Structr because I can finally make the data structure I want thanks to neo4j.

--
You received this message because you are subscribed to the Google Groups "structr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structr+u...@googlegroups.com.
To post to this group, send email to str...@googlegroups.com.
Visit this group at https://groups.google.com/group/structr.
To view this discussion on the web, visit https://groups.google.com/d/msgid/structr/e8a517d4-b207-462e-8650-48410cad5995%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "structr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structr+u...@googlegroups.com.
To post to this group, send email to str...@googlegroups.com.
Visit this group at https://groups.google.com/group/structr.
Message has been deleted

Pete Thornbury

unread,
Jan 6, 2018, 1:35:04 PM1/6/18
to structr
(Post edited...)

Cool thanks, that's very helpful.  I will mess around with this and see what I can do.

Also related (and what originally had me wondering if nesting repeaters was possible) is that the method described in the tutorial, aka just using ${project.projectMembers}, does show a list of projectMembers, but displays their UUIDs rather than their names.  Further down in the tutorial, after setting up edit mode binding, the names of the children do show up when in edit mode, (making selection much easier than having to pick UUIDs) but then switches back to a list of UUIDs display when exiting edit mode into just "view" mode.

I thought, naturally, the answer would be to just replace the template expression I mentioned above with ${project.projectMembers.name} but that doesn't work because project.projectMembers is a list and not a single object, thus it doesn't automatically iterate through the list and display their names (even though it does automatically iterate through the list to display UUIDs...) :-P

Thinking about this led me to figuring out using something like the "each" and "print" built-in functions, and then further also to asking the original question above about nested repeaters... but now my question would be: is there a sanctioned way to do one of these methods that still works with the Edit Mode Binding system?  AKA can I display a list of children objects with more than just their UUIDs that will still work when switching to edit mode?  I will certainly experiment on my own but am curious if there is a "right" way to do it even if I discover a way that kinda works, or appears to work but may actually cause problems down the road.

And maybe I just screwed something up in the tutorial and my ${project.projectMembers} should actually be displaying names in both "view" and "edit" modes.  Either way thanks for your help and I will report back if I discover the obvious answer to editing relationships with multiple children through a Dynamic Output Element using "Interactive Mode" and always showing the name instead of the UUID.

-Pete

(Redundant explanatory rambling language above is mostly for search indexing purposes, sorry!)
Reply all
Reply to author
Forward
0 new messages