Jquery 用作SAPUI5表格列的模板

Jquery 用作SAPUI5表格列的模板,jquery,sapui5,Jquery,Sapui5,有没有一种方法可以定义一个函数,将控件动态返回为SAPUI5表中某列的模板 因此,基本上,模型中的一列包含以逗号分隔的图像链接值,其数量可以从1到多不等。因此,根据链接的数量,我需要在列的同一单元格中显示它们。下面是我写的代码: var oColumn2 = new sap.ui.table.Column({ label: new sap.ui.commons.Label({text: "Fuel Type"}), width: "20%" });

有没有一种方法可以定义一个函数,将控件动态返回为SAPUI5表中某列的模板

因此,基本上,模型中的一列包含以逗号分隔的图像链接值,其数量可以从1到多不等。因此,根据链接的数量,我需要在列的同一单元格中显示它们。下面是我写的代码:

    var oColumn2 = new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Fuel Type"}),
        width: "20%"
    });
    oColumn2.bindAggregation("template", "/modelData", function(sId, oContext) {
        var imgLink = oContext.getProperty("FuelType").split(",");

        var fuelLayout = new sap.ui.commons.layout.MatrixLayout(sId, {
            id : "fuelMatrix",
            layoutFixed : true,
            width:"100%",   
            });

        var fuelRow = new sap.ui.commons.layout.MatrixLayoutRow();
        fuelLayout.addRow(fuelRow);
        var fuelCell = new sap.ui.commons.layout.MatrixLayoutCell();
        fuelRow.addCell(fuelCell);
        for (var n=0; n < imgLink.length; n++){
            fuelCell.addContent(new sap.ui.commons.Image({height:"30%", width:"30%", src:imgLink[n]}))
            }           
        return fuelLayout;
    });
var oColumn2=新的sap.ui.table.Column({
标签:新的sap.ui.commons.label({text:“Fuel Type”}),
宽度:“20%”
});
bindAggregation(“模板”,“模型数据”,函数(sId,oContext){
var imgLink=oContext.getProperty(“FuelType”).split(“,”);
var fuelayout=new sap.ui.commons.layout.MatrixLayout(sId{
id:“fuelMatrix”,
布局固定:正确,
宽度:“100%”,
});
var fuelRow=new sap.ui.commons.layout.MatrixLayoutRow();
fuelLayout.addRow(fuelRow);
var fuelCell=new sap.ui.commons.layout.MatrixLayoutCell();
fuelRow.addCell(燃料电池);
对于(var n=0;n
问题是相同的图像在每一行中重复

您可以使用,而不是控件实例

我已经整理好了,下面是代码的相关部分:

new sap.m.List()
  .bindItems('/people', function(sId, oContext) {
    return (oContext.getProperty('number') % 2) ?
      new sap.m.StandardListItem({
        title: '{name}',
        description: '{number}'
      }) :
      new sap.m.DisplayListItem({
        label: '{name}',
        value: '{number}'
      });
  });

这个简单的示例返回不同样式的列表项,具体取决于项的“number”属性的值是偶数还是奇数。

Hi Abesh,您到底在寻找什么?一个基于特定属性类型动态确定控件(TextView、DatePicker、RadioButton等)的函数?@quality我假设是这样的。