对两个组合的 sap.m.Table 列应用 sap.ui.model.filter



两列firstNamelastName. 如何使用绑定的filter方法,以便从用户输入的搜索字段中的查询John Doe保留firstName+" "+lastName串联匹配的记录?

注意:我在客户端操作模式下执行此操作,因此请不要使用后端过滤解决方案。

正确的解决方案是使用自定义过滤器,如以下人员指出: @Andrii.

因此,我们可以创建一个自定义过滤器,该过滤器将针对表中的每一行运行,并基于返回的布尔值 自定义筛选器 A 行在屏幕上呈现器。筛选器 API:筛选器

因此,下面是运行代码:

handleSearch: function(e) {
var sQuery = e.getParameter('query'); // Fecth search term
var oCustomFilter = new sap.ui.model.Filter({
path:"", // this refers to binding path of each row.
test: function(oNode) {
var oValue = oNode.fname + " " +oNode.lname;
if (oValue.indexOf(sQuery) !== -1) {
return true; // row will be rendererd
} else {
return false; // row will not be rendererd
}
}
});
var oBinding = this._table.getBinding('items');
oBinding.filter(oCustomFilter);
}

桌子:

<Table
id='idTable'
items= "{/}"
>
<columns>
<Column
headerText='FName'
/>
<Column
headerText='LName'
/>  
</columns>
<items>
<ColumnListItem>
<cells>
<Text
text='{fname}'
/>
<Text
text='{lname}'
/>
</cells>
</ColumnListItem>
</items>
</Table>

如果您需要任何其他信息,请告诉我。 :)

最新更新