使用以下代码的过滤器不起作用。我使用Web IDE中的模板创建了一个应用程序,然后将OData绑定到XMLView中的列表中,在搜索上应用过滤器。在UI5中过滤数据
查看:
<SearchField liveChange="onSearch" id="master1SearchField" search="onSearch"/>
<List id="master1List" items="{path:'/DetailsSet'}">
<items>
<ObjectListItem id="master1ListItem">
<attributes>
<ObjectAttribute text="{Name}"/>
</attributes>
</ObjectListItem>
</items>
</List>
控制器:
onSearch : function(oEvent) {
var sFilteredValue = oEvent.getSource().getValue();
var oFilter = new sap.ui.model.Filter("Name", sap.ui.model.FilterOperator.Contains, sFilteredValue);
var oElement = this.getView().byId("table");
var oBinding = oElement.getBinding("items");
oBinding.filter([oFilter]);
}
如果切换到调试模式,您应该在网络选项卡中看到过滤器请求到后端及其响应。 这是否工作?它看起来怎样? 如果你在调试器,什么是“sFilteredValue”这里的价值: “ VAR sFilteredValue = oEvent.getSource()的getValue();” 请也比较样本编码中: https://开头sapui5.hana.ondemand.com/explored.html#/sample/sap.m.sample.ListSelectionSearch/code/List.controller.js –
您是否在正确的控件上应用了过滤器? “oElement”的ID是“table”,而列表的ID是“master1List”。 – boghyon
这里返回什么? 'var sFilteredValue = oEvent.getSource()。getValue();' – neeko