[英]SAPUI5 list/combobox data binding replacing with a table
I have to replace a data binding from a list (combobox) with a table.我必须用表格替换列表(组合框)中的数据绑定。 Its important that we add the filter to have a right data binding in the combobox.
我们添加过滤器以在组合框中拥有正确的数据绑定,这一点很重要。 oInput is defined as a combobox:
oInput 被定义为一个组合框:
oInput.setModel(oView.getModel());
oInput.bindAggregation("items", "/shrhelpSet", oTemplete);
oFilterObject = new sap.ui.model.Filter("object", "EQ", that.g_object);
oFilterField = new sap.ui.model.Filter("field", "EQ",
that.g_TechNameArr[i]);
oFilterLang = new Filter("lang", "EQ", sCurrentLocale);
oFilters = new sap.ui.model.Filter([oFilterObject, oFilterField, oFilterLang], true);
oInput.getBinding("items").filter(oFilters);
My problem is how i can replace it to a binding with a table.我的问题是如何将其替换为带有表格的绑定。 I am using a sap.ui.table in a ValueHelpDialog.
我在 ValueHelpDialog 中使用 sap.ui.table。 I have fixed column data which i definded in an array, and now i need to add the data from the list binding to a array for the row binding.
我已经在数组中定义了固定的列数据,现在我需要将列表绑定中的数据添加到行绑定的数组中。 i defined a array "aData" where i have to put the data of the dataset /shrhelpSet with a filter.
我定义了一个数组“aData”,我必须在其中放置带有过滤器的数据集 /shrhelpSet 的数据。 I tried it with
我试过了
//var aData = this.getModel().getData("/shrhelpSet").filter(oFilters);
But this is the wrong way to do it.但这是错误的做法。
// array with fix column names
var aColumnData = [{
columnId: "Key"
}, {
columnId: "Value"
}];
//var aData = this.getModel().getData("/shrhelpSet").filter(oFilters);
var oModel2 = new sap.ui.model.json.JSONModel();
oModel2.setData({
columns: aColumnData,
rows: aData
});
oTable.setModel(oModel2);
oTable.bindColumns("/columns", function(index, context) {
var sColumnId = context.getObject().columnId;
//alert(sColumnId);
return new sap.ui.table.Column({
id : sColumnId,
label: sColumnId,
template: sColumnId
});
});
oTable.bindRows("/rows");
Try to add the filters to the binding of the rows aggregation like you did before with the items aggregation of the input.尝试将过滤器添加到行聚合的绑定中,就像您之前对输入的项目聚合所做的那样。
oTable.getBinding("rows").filter(oFilters);
This has to be done after the last line of your snippet (after the rows are bound).这有你的代码段的最后一行之后进行(该行绑定后)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.