cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic binding of rows in sap.ui.table.Table using XML views

Former Member
0 Kudos

Hello,

I think this question was asked several times, but it doesn't work in my code.

Does somebody see my mistake or what I´m doing wrong?

I need fully dynamic table (colls and rows). Using the coding below I get the columns but the row data is not displayed.

Could somebody help me?

XML:

<t:Table
 id="table"
 selectionMode="None"
 visibleRowCount="5"
 enableSelectAll="false"
 threshold="15"
 enableBusyIndicator="true"
 columns="{
  	path: 'data>/cols',
  	factory: '.columnFactory'
  	}"
 ariaLabelledBy="title">
 <t:noData>
 <BusyIndicator/>
 </t:noData>
</t:Table>

JS:

onInit: function() {

var cols = [{
	columnName: "123"
	}, {
	columnName: "456"
	}, {
	columnName: "789"
	}];

var rows = [{
	par1: "S",
	par2: "T",
	par3: "C"
	}, {
	par1: "L",
	par2: "",
	par3: "F"
	}, {
	par1: "",
	par2: "Bla",
	par3: "Bla"
	}];

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


oMetaModel.setData({rows: processFlat,
		   cols: cols});


this.getView().byId("table").setModel(oMetaModel,"data");
this.getView().byId("table").bindRows("data>/rows");
},

columnFactory : function(sId, oContext) {
	var tab = this.getView().byId("table");
			
	var colInd = sId.slice(-1);
        var sColumnId = oContext.getModel().oData.cols[colInd].label;
        return new sap.ui.table.Column({           
            label: sColumnId , 
            template: sColumnId, 
            sortProperty: sColumnId, 
            filterProperty: sColumnId});
}

Thank you and regards

Denis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I solved the problem, the column name and the parameter name are to be consistent, since it is automatically applied in the path.

var cols = [{
	columnName: "123"
	}, {
	columnName: "456"
	}, {
	columnName: "789"
	}];

var rows = [{
	123: "S",
	456: "T",
	789: "C"
	}, {
	123: "L",
	456: "",
	789: "F"
	}, {
	...
	}];

Answers (0)