Skip to Content
0
Jul 14, 2016 at 09:17 AM

Create a Table dynamically

2623 Views

Hi Experts,

I have a requirement where I have to create dynamic tabs with table when I hit the service ill get the different types.

For example: I have a service which has multiple types (let say type1 , type2).how many types that I have in service that many icontabFilters i need to create withe respect to table.

I'm getting binding issue for table. Please can any one help me on this.

IconTab--> Main

IcontabFilter1 IcontabFilter2

Table1 table2

Code:

var data = {"TABLES":{}};

for(var i in charctersticTable.getItems()){

var oDynamicTable = new sap.m.Table({

columns:[

new sap.m.Column({

header:[new sap.m.Label({text:"Characteristics"}),

]

})

]

});

var oColumnListItem = new sap.m.ColumnListItem({

cells:[

new sap.m.Label({text:"{CharacteristicsModel>ATBEZ}"})

]

});

var tabl = charctersticTable.getItems()[i]

tabl.addContent(oDynamicTable);

var oGrnam = charctersticTable.getItems()[i].getProperty('text');

var contextFilter = new sap.ui.model.Filter([new sap.ui.model.Filter("GRNAM", sap.ui.model.FilterOperator.EQ,oGrnam),

new sap.ui.model.Filter("CLASS", sap.ui.model.FilterOperator.EQ,"BATCH_CLASS")],true)

var characteristics = [] // which is array it has multiple objects

var oModelChar = this.getView().getModel("CharacteristicsModel");

if(oModelChar !== undefined){

// oModelChar.getData().TABLES[oGrnam]=[];

// for(var i in characteristics){

// oModelChar.getData().TABLES[oGrnam].push(characteristics[i]);

// }

// oModelChar.refresh();

}else{

data.TABLES[oGrnam]= characteristics;

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

this.getView().setModel(oModel, "CharacteristicsModel");

}

oDynamicTable.bindItems("CharacteristicsModel>/TABLES/"+oGrnam,oColumnListItem);

}

Thanks,

Ashok.