DMXzone App Connect Support Product Page

Answered

Multiple Nested Repeats

Asked 01 Apr 2021 15:39:14
1
has this question
01 Apr 2021 15:39:14 Charles Knight posted:
Hi,

Tricky one to explain but here goes...

Have to use a API Data Source string to obtain results from a database query, I can only add items to the url string to gain more output information from predefined fields.

My challenge is to be able to create, using three API connections a dynamic stock list of items.

First repeat shows the records from the categories API's 'Category' field.

Then I have a nested repeat which shows the records from the SubCategory array which is already inside the Category API connection above, this allows me to select the 'SubCategory' field and, as expected shows the results correctly on the page as;

Main Category
- SubCategory

The actual product details are via another API connection 'MachineList' which I want to appear within the second repeat grouped to that subcategory.

I have tried to use the Data Formatting but it only shows values from the MachineList API and not the SubCategory of the second repeat.

Do I need some sort of variable to hold the value of the SubCategory of the second repeat? If so how do I use that variable, I have tried again in the data formatter for the MachineList connection but it comes back with an error all the time saying it expects a colon.

Sorry in advance if this doesn't make sense, I'm finding it hard to explain let alone implement


CK

P.S.
Found this tutorial which sort of does what I need to do but of course I can't create a Server Connect query;

www.dmxzone.com/go/32997/nesting-database-queries/

Replies

Replied 03 Apr 2021 16:25:32
03 Apr 2021 16:25:32 Charles Knight replied:
Have thought about the problem above and I think it needs a conditional 'where' value.

I tried adding 'where' property is category id and value the category id from the second repeat which would make sense and the filter type ==, but all I get is unexpected token, expecting [COLON]. and then the expression below, what am I missing?
Replied 06 Apr 2021 10:35:28
06 Apr 2021 10:35:28 Charles Knight replied:
If its easier to understand the following is what I'm trying to achieve;

DataSource1 (Category and Sub Category)
DataSource2 (Machines)

Repeat1 DataSource1 Category and then repeat2 DataSource1 Sub Category inside repeat1

The bit I can't get is;

Repeat3 DataSource2 inside repeat2 but only showing records where the subcategory of repeat3 is equal to the sub category of repeat2.

<div dmx-repeat:repeat3="MachineList.data.DATA.where(`SUBCATEGORYID`, '{{SUBCATEGORIES[0].ID}}', '==')">{{MANUFACTURER}} {{SUBCATEGORYID}}</div>
Above in bold is wrong but I can't figure out what to put...
Replied 07 Apr 2021 10:36:14
07 Apr 2021 10:36:14 Teodor Kuduschiev replied:
Hello,
Remove the {{ }} around the {{SUBCATEGORIES[0].ID}} in the where expression. You can't use {{ }} in expressions.
Replied 07 Apr 2021 15:36:18
07 Apr 2021 15:36:18 Charles Knight replied:
Thanks Teodor but this doesn't really answer my original question or problem...

I have tried a different method from a tutorial I found which uses a 'groupBy' on the first repeat and then the has the $key as its App Connect Binding and then the second repeat uses the $value of the first repeat for its App Connect Expression, below is my code:


<div dmx-repeat:repeat1="MachineList.data.DATA.groupBy(`SUBCATEGORY`)"><span style="color:red">{{$key}}</span><div dmx-repeat:repeat2="$value">{{MAKES}}</div></div>


The above works but I still have one problem. The second repeat has records which also need to be grouped together but there is no option to groupBy on the $value expression, can you suggest a way please? The field I want to group by is a number field.

Many thanks
CK
Replied 07 Apr 2021 16:34:43
07 Apr 2021 16:34:43 Teodor Kuduschiev replied:
Sorry but i am not sure i understand you.
I provided the code you need - does it work or not?
This reply was removed on 4/8/2021 9:01:45 AM.
See the changelog
Replied 08 Apr 2021 09:10:19
08 Apr 2021 09:10:19 Charles Knight replied:
Yes, taking out the {{}} in the expression makes it work.
Thank you
Replied 08 Apr 2021 09:12:52
08 Apr 2021 09:12:52 Charles Knight replied:
My third repeat, below, is there a way to set the order of the repeat on the UNITS binding?


<div dmx-repeat:repeat3="MachineList.data.DATA.where(`SUBCATEGORYID`, ID, '==')">{{MANUFACTURER}} {{SUBCATEGORYID}} - Units={{UNITS}}</div>

Replied 08 Apr 2021 13:24:20
08 Apr 2021 13:24:20 Teodor Kuduschiev replied:

dmx-repeat:repeat3="MachineList.data.DATA.where(`SUBCATEGORYID`, ID, '==').sort('UNITS')"

Replied 08 Apr 2021 13:59:34
08 Apr 2021 13:59:34 Charles Knight replied:
Great thank you
Replied 08 Apr 2021 14:13:22
08 Apr 2021 14:13:22 Charles Knight replied:
How could I sort on more than one field, would it be;

dmx-repeat:repeat3="MachineList.data.DATA.where(`SUBCATEGORYID`, ID, '==').sort('UNITS', 'MAKE')"
Replied 08 Apr 2021 14:28:57
08 Apr 2021 14:28:57 Teodor Kuduschiev replied:
Unfortunately that is not possible.

Reply to this topic