无法在 DevExpress 中本地筛选数据

Cannot filter data Locally in DevExpress

本文关键字:筛选 数据 DevExpress      更新时间:2023-09-26

我从数据库中得到的结果为

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。而且我没有得到结果。我可以知道我犯了什么错误吗?

提前致谢

请更改

"&&",

"and",

根据组过滤器操作的规范,它必须是"and""or"