sapui5 - Dynamic Table binding
问题描述
Please suggest. Table binding does not work. Model Data and may change:
{ "TestCloudEnvRO": [ { "pipelineName": "RP1", "cycles": [ "cy1", "cycle1", "RP1cy2", "cyc2", "crCycle" ] }, { "pipelineName": "RP2", "cycles": [ "BP1-c2", "bp2-cy" ] }, { "pipelineName": "RPlocal", "cycles": [ "cyclelocal" ] }, { "pipelineName": "rp1234", "cycles": [ "cyclert" ] }, { "pipelineName": "RPTEST", "cycles": [ "BPTEST1" ] }, { "pipelineName": "rp123", "cycles": [ "cytr" ] } ] }
View
<Table id="idtrlAllPipelines" alternateRowColors="true">
<columns>
<Column demandPopin="true" minScreenWidth="Tablet">
<Text text="Release Pipeline Cycles"/>
</Column>
</columns>
Controller
var oTemplate = new sap.m.ColumnListItem({ cells: [ new sap.m.Text({ text: "{getHist>pipelineName}" }) ] }); this.byId("idtrlAllPipelines").setModel(oModelEnv, "getHist");
this.byId("idtrlAllPipelines").bindAggregation("items", { path: "getHist>/TestCloudEnvRO", template: oTemplate, templateShareable: true } );
It does not load any items in the table. But this works at View. I have to replace this with /TestCloudEnvRO with selected key of Icon tab filter, so the above should work. Please suggest.
<Table items="{path: 'getHist>/TestCloudEnvRO'}" id="idtrlAllPipelines" alternateRowColors="true">
解决方案
对于您建议的绑定,您的数据集可能需要稍作修改才能达到要求。PFB 代码。
控制器
loadDataSet: function () {
var oMasterModel = this.getView().getModel("oMasterModel");
var oDataSet = [{
"IconTabName": "Env1",
"Table": [{
"name": "Person1",
"runs": ["10", "20"]
}, {
"name": "Person2",
"runs": ["0", "2"]
}]
}, {
"IconTabName": "Env2",
"Table": [{
"name": "Person3",
"runs": ["5", "25"]
}, {
"name": "Person4",
"runs": ["20", "12"]
}]
}];
oMasterModel.setData({
allFilters: oDataSet
});
oMasterModel.refresh(true);
}
看法
<IconTabBar items="{oMasterModel>/allFilters}">
<items>
<IconTabFilter text="{oMasterModel>IconTabName}">
<Table items="{oMasterModel>Table}">
<columns>
<Column>
<Label text="Name"/>
</Column>
<Column >
<Label text="Runs"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{oMasterModel>name}"/>
<Select items="{oMasterModel>runs}">
<core:Item text="{oMasterModel>}"/>
</Select>
</cells>
</ColumnListItem>
</items>
</Table>
</IconTabFilter>
</items>
</IconTabBar>
推荐阅读
- python - 单击 selenium python 的 div 弹出窗口上的提交按钮
- ios - 在firebase中,是否可以在不知道第一个节点的值的情况下在第二级节点进行查询?
- c# - WPF 设计时数据未绑定到图像
- vmware - ISCSI - 1GB/s 磁盘读取导致 8GB/s 网络使用
- sql - 使用 & 运算符的 MS Access 查询
- c - 与 sudo 一起使用时,fork() 和 execvp() 出现意外结果
- java - 在 Java Spark 中收集数据集时出现 OutOfMemoryError GC 开销限制
- python - 如何通过 ssh 访问远程服务器上运行的 Jupyter notebook 中本地机器的输入设备?
- c# - 检测意图响应 - Unity 和 Dialogflow
- c++ - 如何建立解放