Sapui5 在表列中填充组合框
我用一张桌子系了一个小木偶模型。表中的一列是下拉列表。该列表有大约3个值。这对我来说有点困惑,但如何处理这种情况呢?我是否必须绑定另一个包含下拉列表中所需值的模型,然后将其属性绑定到来自绑定到表的ODataModel的响应 以下是正确的吗?但是如果我在下拉列表中有更多的值,或者更多的值,那可能就不好了。。。。如果我想将下面提到的密钥与ODataModel中的状态绑定,如何继续?在这里,我将combobox的value属性与来自ODataModel的StatusText绑定。 但是我想将ListItem的键属性与ODataModel中的Status绑定,ODataModel与表响应绑定Sapui5 在表列中填充组合框,sapui5,Sapui5,我用一张桌子系了一个小木偶模型。表中的一列是下拉列表。该列表有大约3个值。这对我来说有点困惑,但如何处理这种情况呢?我是否必须绑定另一个包含下拉列表中所需值的模型,然后将其属性绑定到来自绑定到表的ODataModel的响应 以下是正确的吗?但是如果我在下拉列表中有更多的值,或者更多的值,那可能就不好了。。。。如果我想将下面提到的密钥与ODataModel中的状态绑定,如何继续?在这里,我将combobox的value属性与来自ODataModel的StatusText绑定。 但是我想将ListI
oTable.addColumn(
new sap.ui.commons.ComboBox({
items: [
new sap.ui.core.ListItem({text: "New",key:"1"}).bindProperty("text","StatusText").bindProperty("key","Status"),
new sap.ui.core.ListItem({text: "In Process",key:"2"}),
new sap.ui.core.ListItem({text: "Completed",key:"3"})
]
}).bindProperty("value","StatusText")
);
任何帮助都将不胜感激
谢谢这在表中有效,但我认为您的组合框在绑定方面仍然存在一些错误
var oCombobox = new sap.ui.commons.ComboBox({
items: [
new sap.ui.core.ListItem({text: "New",key:"1"}).bindProperty("text","StatusText").bindProperty("key","Status"),
new sap.ui.core.ListItem({text: "In Process",key:"2"}),
new sap.ui.core.ListItem({text: "Completed",key:"3"})
]
}).bindProperty("value","StatusText");
oTable.addColumn(new sap.ui.table.Column({
template : oCombobox,
visible : true,
}));
假设您有一个名为{Firstname}的oData字段,该字段在结果类型表中定义,例如,对于该表,然后将其绑定到表中,如下所示:
oTable.addColumn(new sap.ui.table.Column({
template : new sap.ui.commons.TextView({
text : "{Firstname}",
textAlign : sap.ui.core.TextAlign.Center
}),
visible : true,
}));
据我所知,您希望从oData服务中获取可能的值,但我认为这在下拉/组合框的情况下是不可能的,因为您从后端获取一个表,每行在一个字段中有一个值->如何将3个值绑定到一个表字段中
我在自己的服务中实现了下拉,分别从后端调用下拉值:
getDropdown : function() {
// Create JSON data model
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData("/sap/opu/odata/sap/YOUR_SERVICE/YourEntitySet");
sap.ui.getCore().setModel(oModel);
// Create a DropdownBox
var oDropdown = new sap.ui.commons.DropdownBox("DropdownBox", {
text: "{Firstname}",
});
oDropdown.setModel(oModel);
var oItemTemplate1 = new sap.ui.core.ListItem({
text : "{Firstname}",
});
oDropdown.bindItems("/d/results", oItemTemplate1);
// "/d/results" may vary depending on your path
// return the box
return oDropdown;
},
您可以在表中使用返回的结果
e、 g.鉴于:
var dropdown = oController.getDropdown();
dropdown.placeAt("content");
我希望我明白了你的意思,但我认为绑定主题对我来说并不清楚:-