无法在DevExpress中本地过滤数据

时间:2016-02-03 10:16:20

标签: javascript json devexpress

我从数据库得到了

的结果
var dataSource = [{ "ID": 1, "ProductName": "P1", "InYear": 2015, "Revenue": 500 },
   { "ID": 2, "ProductName": "P2", "InYear": 2015, "Revenue": 700 },
   { "ID": 3, "ProductName": "P3", "InYear": 2015, "Revenue": 600 },
   { "ID": 4, "ProductName": "P1", "InYear": 2016, "Revenue": 800 },
   { "ID": 5, "ProductName": "P2", "InYear": 2016, "Revenue": 900 },
   { "ID": 6, "ProductName": "P3", "InYear": 2016, "Revenue": 400 }]

我需要过滤数据。所以我使用过滤器选项如下

 var newDataSource = new DevExpress.data.DataSource({
                     dataSource: dataSource,
                    filter: [
                        ["InYear", ">=", startFromYear],
                     "&&",
                        ["InYear", "<=", endWithYear]
                    ],

                });

其中startFromYear = 2014年和endWithYear = 2016年。

我用过

  newDataSource.load();
  alert('length'+newDataSource.items.length);
 $('#chartContainer').dxChart('instance').option('dataSource', newDataSource);

过滤后我得到长度= 0的结果。我没有得到结果。我可以知道我犯了什么错误吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

请更改

"&&",

"and",

根据Group Filter Operations的规范,它必须是"and""or"