Reputation: 119
I have a sap.ui.table.Table which I want to make editable. In the SAPUI5 Samples I can see that SAP replaces the m.Texts with m.Inputs in the column list items of a sap.m.Table. I have a sap.ui.table.Table and at the moment I don't know how I can change the template of a sap.ui.table.Table in the controller. What I need is to change the template of my columns or rows. I did the binding in the View, like:
<ui:columns>
<ui:Column>
<m:Label text="label"/>
<ui:template>
<m:Text text="{xx}"/>
</ui:template>
</ui:Column>
</ui:columns>
but I have to define the template in the controller. I tried following:
var oTemplateTable = new sap.ui.table.Row({
cells: [
new sap.m.Text({
text: "{xxx}"
}),
// ... further cells per row
],
});
oTableRunC.bindRows({
path: sBindingPathRunC,
template: oTemplateTable
});
but this doesnt work because I think I have nowhere defined the fixed columns. What did I forget to define? My goal is to bind the sap.ui.table.Table with the bindRows method in the controller and set the template or the ui elements of my rows in the same step. So I can implement a method for editing the table where I put m.Input elements in the rows and a display data method where m.Texts are visible for only showing the table data.
Upvotes: 0
Views: 2133
Reputation: 753
To update the template, you should can set the template aggregation of the sap.ui.table.Column in your controller e.g.
var oProductNameColumn = this.byId("ProductNameColumn");
oProductNameColumn.setTemplate(new sap.m.Input({value: "{ProductName}"}));
see the documentation of the template aggregation for more details. https://ui5.sap.com/#/api/sap.ui.table.Column%23aggregations
Upvotes: 3