我想只显示属性title!==null
var filter = new sap.ui.model.Filter({path:"title",test:function(oValue){
return oValue!==null;
}
});
但是我遇到了错误:Wrong parameters defined for filter.
这是我使用的API:https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.Filter.html
如何正确设置过滤器?
我已经更新了运行时,现在我可以使用我的个人测试功能来测试平铺!
答案 0 :(得分:1)
为参数映射的test
属性指定函数的能力出现在1.26中。在以前的版本1.24中,这是不可能的。根据你的评论你运行1.24,因此错误。
FWIW,这是1.24对1.26中sap / ui / model / Filter.js的细节:
1.24:
/**
* Constructor for Filter
* You can either pass an object with the filter parameters or use the function arguments
*
* Using object:
* new sap.ui.model.Filter({
* path: "...",
* operator: "...",
* value1: "...",
* value2: "..."
* })
*
* OR:
* new sap.ui.model.Filter({
* filters: [...],
* and: true|false
* })
1.26:
/**
* Constructor for Filter
* You can either pass an object with the filter parameters or use the function arguments
*
* Using object:
* new sap.ui.model.Filter({
* path: "...",
* operator: "...",
* value1: "...",
* value2: "..."
* })
*
* OR:
* new sap.ui.model.Filter({
* path: "...",
* test: function(oValue) {
* }
* })
*
* OR:
* new sap.ui.model.Filter({
* filters: [...],
* and: true|false
* })