选择器中不显示 SAPUI5 文本
SAPUI5 text is not displayed in Selector
我阅读了文档 https://sapui5.hana.ondemand.com/#/entity/sap.m.Select/sample/sap.m.sample.Select/code,我想在我的代码中创建一个选择器。
我仔细按照文档操作,但没有显示文本。
在我的 XML 文件中:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/SelectedProduct/ProductId}" text="{test>/SelectedProduct/Name}" />
</Select>
在我的控制器文件中:
var oData = {
"SelectedProduct": "HT-1001",
"SelectedProduct2": "HT-1001",
"SelectedProduct3": "HT-1001",
"ProductCollection": [
{
"ProductId": "HT-1000",
"Name": "Notebook Basic 15"
},
{
"ProductId": "HT-1001",
"Name": "Notebook Basic 17"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
}
],
"Editable": true,
"Enabled": true
};
var oModel = new JSONModel(oData);
this.getView().setModel(oModel, "test");
它不显示文本,但显示数组元素的数量。
我也试过:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/ProductCollection/ProductId}" text="{test>/ProductCollection/Name}" />
</Select>
并且:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/ProductCollection.ProductId}" text="{test>/ProductCollection.Name}" />
</Select>
为什么此解决方案无法按预期工作?
项目绑定路径中不需要 ProductCollection
。项目路径已设置为 ProductCollection
in Select。
<core:Item key="{test>ProductId}" text="{test>Name}" />
我阅读了文档 https://sapui5.hana.ondemand.com/#/entity/sap.m.Select/sample/sap.m.sample.Select/code,我想在我的代码中创建一个选择器。
我仔细按照文档操作,但没有显示文本。 在我的 XML 文件中:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/SelectedProduct/ProductId}" text="{test>/SelectedProduct/Name}" />
</Select>
在我的控制器文件中:
var oData = {
"SelectedProduct": "HT-1001",
"SelectedProduct2": "HT-1001",
"SelectedProduct3": "HT-1001",
"ProductCollection": [
{
"ProductId": "HT-1000",
"Name": "Notebook Basic 15"
},
{
"ProductId": "HT-1001",
"Name": "Notebook Basic 17"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
},
{
"ProductId": "HT-1002",
"Name": "Notebook Basic 18"
}
],
"Editable": true,
"Enabled": true
};
var oModel = new JSONModel(oData);
this.getView().setModel(oModel, "test");
它不显示文本,但显示数组元素的数量。
我也试过:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/ProductCollection/ProductId}" text="{test>/ProductCollection/Name}" />
</Select>
并且:
<Select
selectedKey="{test>/SelectedProduct}"
items="{
path: 'test>/ProductCollection',
sorter: { path: 'Name' }
}">
<core:Item key="{test>/ProductCollection.ProductId}" text="{test>/ProductCollection.Name}" />
</Select>
为什么此解决方案无法按预期工作?
项目绑定路径中不需要 ProductCollection
。项目路径已设置为 ProductCollection
in Select。
<core:Item key="{test>ProductId}" text="{test>Name}" />