Nested components
Components can be nested, so that one component may list a set of datasets and the dataset's display (inside the swac_repeatedForSet) contains another component that displays details.
Nested component with useage of parents data
If the child component should use the same data as the parent component
simply use a component requestor without FROM-clause.
Scince every component div needs a id
and every id must be unambiguous use the {id} from the parent dataset
to identify the child component.
<div id="nested_example1" swa="Present FROM ../../data/exampledata_object.json">
<div class="swac_repeatForSet">
The nested data of {name} is:
<div id="nested_example1_child_{id}" swa="Present"></div>
</div>
</div>
Nested component with own data
If the child component has its own data without reference to the data of the parent its simple. Only put the child component in parents template.
<div id="nested_example1" swa="Present FROM ../../data/exampledata_object.json">
<div class="swac_repeatForSet">
The dataset {name} is one of:
<div id="nested_example1_child_{id}" swa="Present FROM ../../data/exampledata_list.json"></div>
</div>
</div>
Filter nested sets
The datasets show in the nested component can be filtered.
In folowing example only datasets are shown in the nested component,
that have the value of parents set {id} in their attribute "simpleref".
<div id="nested_example1" swa="Present FROM ../../data/exampledata_object.json">
<div class="swac_repeatForSet">
The dataset {name} (id: {id}) is refenced by set (over attribute simpleref):
<div id="nested_example1_child_{id}" swa="Present FROM ../../data/exampledata_list.json WHERE filter=simpleref,eq,{id}"></div>
</div>
</div>
Nested component without data
Sometimes you need a nested component that does not get data at page load nor from parent set and from own datasource. For this cases use FROM none to create an empty component. This can be filled with data over javascript later.
<div id="nested_example1" swa="Present FROM ../../data/exampledata_object.json">
<div class="swac_repeatForSet">
The dataset {name} (id: {id}) has a empty sub component:
<div id="nested_example1_child_{id}" swa="Present FROM none"></div>
</div>
</div>
Filter for parent and child sets
With options.mainSource you can set a souce which holds the main data
for your component. All Datasets from this source are named parent sets.
All other sets from other sources are child sources.
If you use this mechanism you can define rules, when to accept the
sets in your component. This works on nested components, too.
<div id="nested_example1" swa="Present FROM ../../data/exampledata_object.json">
<div class="swac_repeatForSet">
The dataset {name} (id: {id}) has a empty sub component:
<div id="nested_example1_child_{id}" swa="Present FROM none" parentFilter="id,eq,{id}" childFilter="ref_id,eq,{id}"></div>
</div>
</div>