on 11-28-2016 10:55 AM
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
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"
}, {
...
}];
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.