Given scenario below:
Models:
Projects
Tasks
and
Relationship:
Projects (one) <--> (many) Tasks
I have an accordion with the datasource that only shows Projects with uncompleted tasks. (e.g., query.filters.Tasks.Completed._equals = false)
In the accordion detail I have a list where I only want to show tasks that meet a certain criteria (eg. Task.Category = "Marketing" OR "Sales").
Is this possible, and if so, how would this be done?
onDataLoad
event of the Accordion's details prototype// Accordion details onDataLoad event handler
var ds = app.datasources.TasksFitered;
var projectKey = widget.datasource.item._key;
ds.query.filters.Category._in = ['Marketings', 'Sales'];
ds.query.filters.Project._key._equals = projectKey;
ds.load();
Most likely you'll need to unload the datasource on onDetach event of the details, to hide old results when user switches between projects:
// Accordion details onDetach event handler
app.datasources.TasksFitered.unload();