问题
How can I use the query/filter function to filter out two categories of the same field.
Example which currently works to filter "Completed" task:
var datasource = app.datasources.Project;
datasource.query.filters.Status._notContains = 'Completed';
datasource.load();
But I would like to have it filter both "Completed" AND "Canceled" tasks.
I tried these, but they didn't seem to work:
Example 1
var datasource = app.datasources.Project;
datasource.query.filters.Status._notContains = 'Completed';
datasource.query.filters.Status._notContains = 'Canceled';
datasource.load();
Example 2
var datasource = app.datasources.Project;
datasource.query.filters.Status._notContains = 'Completed', 'Canceled';
datasource.load();
Any help would be appreciated. Thanks!
回答1:
To achieve this, instead of using _notContains
, please use _notIn
the following way:
var datasource = app.datasources.Project;
var statuses = ['Completed', 'Canceled'];
datasource.query.filters.Status._notIn = statuses;
datasource.load();
Please refer to the official documentation for a better and more detailed explanation. I hope this helps!
来源:https://stackoverflow.com/questions/42405004/how-can-i-filter-multiple-variables-in-a-table