Reputation: 570
I have a table:
<Table id="Listing" class="tableList" mode="MultiSelect" items="{path: 'masterData>/contactsList'}">
<columns>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>vendorNum}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>recipientType}"/>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<Text text="{i18n>supplierName}"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text text="{masterData>vendorNum}"/>
</cells>
<cells>
<Text text="{masterData>recipientType}"/>
</cells>
<cells>
<Text text="{masterData>supplierName}"/>
</cells>
</ColumnListItem>
</items>
</Table>
And i have a method for export data to csv:
onExportCSV:function() {
//... then I want to get the data in the form of an object - sContent
oExport.generate().done(function(sContent) {
var uri = 'data:text/csv;charset=utf-8,' + sContent;
var downloadLink = document.createElement("a");
downloadLink.href = uri;
downloadLink.download = "data.csv";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
console.log(sContent);
}).always(function() {
this.destroy();
});
}
How do I get the current data in the table for further exports to the csv? At the same time, for this, I am not in any case should not get these data on the server.
Upvotes: 0
Views: 1366
Reputation: 1826
Here is an example of how you can get the table's content:
onPress: function(){
var aTableRows = sap.ui.getCore().byId(this.createId("Listing")).getItems();
console.log("Table rows: ",aTableRows);
for(var i=0; i< aTableRows.length; i++){
console.log("Row "+(i+1)+" cells: ", aTableRows[i].getCells());
var aRowCells = aTableRows[i].getCells();
for(var j=0; j < aTableRows[i].getCells().length; j++){
console.log("Row "+(i+1)+" cell "+(j+1)+" value: ", aRowCells[j].getText());
}
}
}
Here is a working example, the data is printed to the console.
After that, you can set up this data as you wish.
Upvotes: 1