DMXzone Server Data Formatter Support Product Page

Answered

How can I filter a nested repeat region so it only show the results that match the parent region?

Asked 02 Aug 2017 15:44:40
1
has this question
02 Aug 2017 15:44:40 Lee Woolsey posted:
I have a nested repeat region table, I need the nested region to display a total that is made up of a sum of related records.

Here is the code for the nested table:

 <div class="table-responsive">
          <table class="table table-striped table-bordered table-condensed">
            <thead>
              <tr>
                <th>&nbsp;</th>
                <th>Name</th>
                <th>Age</th>
                <th>State</th>
                <th>Rank</th>
                <th>Instructor name</th>
                <th>Dojo name</th>
                <th>&nbsp;</th>
              </tr>
            </thead>
            <tbody data-binding-repeat-children="{{standingsAllX.data.membersByPoints}}" data-binding-id="tableRepeat">
              <tr>
                <td align="center">[img]pix/thumb_{{dojo_logo}}" alt="" height="25"/></td>
                <td>{{name_f}} {{name_l}}</td>
                <td align="center">{{dob.dateDiff( "years", "" )}}</td>
                <td align="center">{{state}}</td>
                <td align="center">{{rank}}</td>
                <td>{{instructorName}}</td>
                <td>{{dojoName}}</td>
                <td><div data-binding-id="allPointsRepeat" data-binding-repeat="{{standingsAllX.data.memberRepeat}}">{{allPoints.sum( "points" )}} | {{ieaauID}} |  </div></td>
              </tr>
            </tbody>
          </table>


In this example I have three records that display, and the sum of the individual points is accurate, however all three results are displayed in each row of the table. How do I limited the displayed total to match only the record ID of the row it is displayed in? I've try every combination of filters I can think of, but only can only get it to display the first record. (NOTE: the second field displayed {{ieaauID}} is only there so I can verify that that the totals are being correctly summed for the ID they are related to.)

Replies

Replied 03 Aug 2017 07:17:33
03 Aug 2017 07:17:33 Teodor Kuduschiev replied:
Hi Lee,
In your case probably you can just use the Group By filter: www.dmxzone.com/go/32971/using-the-group-by-filter
Replied 03 Aug 2017 13:16:15
03 Aug 2017 13:16:15 Lee Woolsey replied:
Where would I apply the Group by filter in the Query or in the repeat region of the table?

I tried that in the Query an got an [object.object] displayed on the results page.
Replied 03 Aug 2017 13:37:24
03 Aug 2017 13:37:24 Teodor Kuduschiev replied:
What exactly do you mean? Please check the video - it explains how to set this up.
Replied 03 Aug 2017 15:10:09
03 Aug 2017 15:10:09 Lee Woolsey replied:
My action file has a primary query that select all of the members, then in a repeat there is a second query which selects all 'score' records filtered by matching the member id (ieaauID). It is the result of this repeated query that is being displayed in the table. However, ALL the records (summed) for every member all appearing. I would like to limit the sum to the matching record in the parent query.
Replied 03 Aug 2017 15:25:47
03 Aug 2017 15:25:47 Teodor Kuduschiev replied:
Can you send me a screenshot of how is your server action set up exactly and what expression is the repeat step using as well as what expression is the filter for nested query using?
Replied 04 Aug 2017 02:41:32
04 Aug 2017 02:41:32 Lee Woolsey replied:
I have screen shots, but I cannot figure out how to upload them here. Is there another address I can send them?
Replied 04 Aug 2017 02:53:43
04 Aug 2017 02:53:43 Lee Woolsey replied:
Screen shots in zipfile:
Replied 04 Aug 2017 06:49:13
04 Aug 2017 06:49:13 Teodor Kuduschiev replied:
I think i see the problem.
You should create the main repeat on your page out of the memberRepeat:


And not from the query itself. That is the point of repeating the query - it repeats it per user, and then you use this repeat as a source for the main repeat region.
Replied 04 Aug 2017 13:23:06
04 Aug 2017 13:23:06 Lee Woolsey replied:
That is essentially what the 'memberByPoints' query is. I added the 'memberRepeat' in the server action file to access the field values for the 'allPoints' query.

How do I retrieve those values for the 2nd query without using the repeat? I've watched the videos for doing this using a form, but have not found a reference for passing those values from within the repeating table itself. I've tried using a URL variable, but don't know how update it's value on each pass...
Replied 04 Aug 2017 13:33:28
04 Aug 2017 13:33:28 Teodor Kuduschiev replied:
It is right how you've set it up.
What is wrong is that on the page you should be using the memberRepeat as a source for the main repeat!
Replied 04 Aug 2017 22:27:29
04 Aug 2017 22:27:29 Lee Woolsey replied:
THANK YOU!!

I hadn't realized that it was possible to use the repeat in the query as the source for the main repeat. I works as intended now.

Thank you again for your insight,
Replied 05 Aug 2017 07:13:11
05 Aug 2017 07:13:11 Teodor Kuduschiev replied:
Yes, not only it is possible, but in cases like this it exactly what you should be using.
When repeating a query, just turn off the "output" option for it (for the query in the server connect panel), so you don't get confused seeing them both in the data bindings panel. This way you will only see the repeat and the nested query inside it.
Replied 09 Aug 2017 00:29:12
09 Aug 2017 00:29:12 Lee Woolsey replied:
Can I have the results sorted by the value of nest query? I tried several versions of the following without any luck.


 <tbody data-binding-repeat-children="{{standingsAllX.data.memberRepeat.sort( &quot;allPoints.sum( &quot;points&quot; )&quot; )}}" data-binding-id="tableRepeat">



Reply to this topic