Reputation: 671
I'm trying to select all recods that user checked, but I can't. Using the code:
var gettingInternalTable = this.byId("bpTable").getTable(),
gettingAllRows = gettingInternalTable.getRows();
I can get all the rows that have been showing in my screen, but I can't filter then by the checkbox. I'm using the smartTable to show the data.
Follow it's my link:
This is my View:
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:smartTable="sap.ui.comp.smarttable"
controllerName="opensap.odataBasic.controller.App" height="100%">
<Page title="{i18n>appTitle}">
<content>
<smartTable:SmartTable id="bpTable" header="{i18n>UList}" editable="false"
showRowCount="true" enableAutoBinding="true"
showFullScreenButton="true" tableType="Table">
<smartTable:layoutData>
<FlexItemData growFactor="1" baseSize="0%"/>
</smartTable:layoutData>
<smartTable:customToolbar>
<OverflowToolbar width="100%" id="toolbar2">
<content>
<Button xmlns="sap.m" text="Button" id="button"
press=".reprocessSelectedRecords"/>
</content>
</OverflowToolbar>
</smartTable:customToolbar>
</smartTable:SmartTable>
</content>
</Page>
</mvc:View>
This is my controller:
onInit: function () {
this.getView().addStyleClass("sapUiSizeCompact");
var oConfig = this.getOwnerComponent().getModel("config");
var userName = oConfig.getProperty("/UserName");
var bpModel = this.getOwnerComponent().getModel("bpModel");
var oTable = this.getView().byId("bpTable");
//To-Do Bind Model to table
oTable.setModel(bpModel);
oTable.setEntitySet("OZPSTA_MON_ERROR");
oTable.setInitiallyVisibleFields("id", "codigo_atena", "hora", "data", "flag",
"tableName", "field", "erro", "operacao");
},
reprocessSelectedRecords: function (oEvent) {
var gettingInternalTable = this.byId("bpTable").getTable(),
gettingAllRows = gettingInternalTable.getRows();
gettingAllRows.map(function (item) {
// get the selected rows
});
}
Upvotes: 0
Views: 5123
Reputation: 408
You can try to get the selected rows in the following way-
var gettingInternalTable = this.byId("bpTable").getTable(),
gettingAllRows = gettingInternalTable.getRows();
oSelIndices = gettingInternalTable.getSelectedIndices();
//oSelIndices will have index of the rows
for(var i of oSelIndices){
console.log(gettingAllRows[i].getBindingContext().getObject())
}
Upvotes: 2