Dynamic binding of table column and rows

后端 未结 1 771
情深已故
情深已故 2020-12-05 08:13

I\'m having troubles getting dynamic binding of both my table columns and rows to work.

Suppose I have two models, one holding the table column info:



        
相关标签:
1条回答
  • 2020-12-05 09:10

    I have done something similar before using factory functions see jsbin example for similar example to yours

    var oTable = new sap.ui.table.Table({
        title: "Table column and data binding",
        showNoData : true,  
        columnHeaderHeight : 10,
        visibleRowCount: 7
    });
    oTable.setModel(oModel);
    oTable.bindColumns("/columns", function(sId, oContext) {
        var sColumnId = oContext.getObject().columnId;
        return new sap.ui.table.Column({
            id : sColumnId,
            label: sColumnId, 
            template: sColumnId, 
            sortProperty: sColumnId, 
            filterProperty: sColumnId
        });
    });
    oTable.bindRows("/rows");
    

    you could use 2 globally named models in this scenario, one for the metadata one for the data eg

    sap.ui.getCore().setModel(oMetaModel, 'meta');
    sap.ui.getCore().setModel(oDataModel, 'data');
    ..
    oTable.bindColumns("meta>/columns" function...
    oTable.bindRows("data>/rows");
    

    Heres an example jsbin example of dynamic columns based on OData metadata

    0 讨论(0)
提交回复
热议问题