How Can I Filter Multiple Variables In A Table?

怎甘沉沦 提交于 2019-12-30 07:42:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!