Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to develop sap.m.Table dynamically?

Hi all,

i am devloping a sapui5 application in that i am developing a dynamic table i am using following code for that

var oModel23 = new sap.ui.model.json.JSONModel();

  oModel23.setData({

  columns : aColumnData,

  rows    : aData

  });

  var oTable = sap.ui.getCore().byId('__xmlview4--Maintenanclevel');

  oTable.setModel(oModel23);

  // oTable.setEditable();

  oTable.bindColumns("/columns", function(sId, oContext) {

  var sColumnId = oContext.getObject().FIELDNAME;

  var sColumnname = oContext.getObject().SCRTEXT_M;

  return new sap.ui.table.Column({

  id : sColumnId,

  label: sColumnname,

  template: sColumnId,

  sortProperty: sColumnId,

  filterProperty: sColumnId

  });

  });

  oTable.bindRows("/rows");                                   

but i want sap.m.table i mean this is an normal table


so how can i develop sap.m.Table dynamically like as above                          

Tags:
Former Member
Former Member replied

hi all

i solved my problem using below code

var oModel23 = new sap.ui.model.json.JSONModel();
oModel23.setData({
columns : aColumnData,
rows    : aData
});
var oTable = sap.ui.getCore().byId('__xmlview4--Maintenanclevel');
oTable.setModel(oModel23);
oTable.bindAggregation("columns", "/columns", function(index, context) {
var sColumnId = context.getObject().FIELDNAME;
var sColumnname = context.getObject().SCRTEXT_M;

        return new sap.m.Column({

            header: new sap.m.Label({text: sColumnname}),

        });

    });

    oTable.bindItems("/rows", function(index, context) {

        var obj = context.getObject();

        var row = new sap.m.ColumnListItem();

     

for(var k in aColumnData) {

            var x  = aColumnData[k].FIELDNAME;

           row.addCell(new sap.m.Text({text : obj[x]}));

        }

        return row;

    });

my output now like below  

Thanks,

Kotesh.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question