cancel
Showing results for 
Search instead for 
Did you mean: 

How to get selected row in SMARTTABLE

Former Member
0 Kudos
5,389

Hi Expert,

Iam using smarttable from class "sap.ui.comp.smarttable.SmartTable" .

I was not able to find a method to get the selected row .

Please could you help me how to get the selected row based on click on delete button.

<smartTable:SmartTable id="smarttable" entitySet="ZOMPC_DTL_FIORISet" smartFilterId="smartFilterBar" tableType="Table" 
 useExportToExcel="true" useVariantManagement="false" 
useTablePersonalisation="true" header="Line Items" 
showRowCount="true" persistencyKey="SmartTableAnalytical_Explored" 
enableAutoBinding="true" 
app:useSmartField="true" class="sapUiResponsiveContentPadding" 
editTogglable="true" 
initiallyVisibleFields="Posnr,Prctr,Sdesc,Amount,Status,Unallocated,Realized,Head_qrt_flag,Ordrec_qrt,Ordrec_qrt,Pnl_amount" 
tableBindingPath="ZOMPC_DTL_FIORISet">
<smartTable:customToolbar> 
<OverflowToolbar design="Transparent"> 
<ToolbarSpacer/> 
<Button icon="sap-icon://add" text="Row" press="addRow"/>
<Button icon="sap-icon://delete" text="Delete" press="deleteRow"/>
</OverflowToolbar> 
</smartTable:customToolbar>	
</smartTable:SmartTable>
 

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

If you have default table inside smart Table you can use all its methods i.e for sap.m.Table.

<smartTable:SmartTable id="smarttable" ... >
<Table id="innerTable" mode="MultiSelect" selectionChange=".onRowSelect">
  <columns>
    <Column>
<core:CustomData key="p13nData" value='\{"columnKey": "Price", ...

    </Column>
  </columns>

  <items>
    <ColumnListItem>
      <cells>
         ...
      </cells>
    </ColumnListItem>
  </items>

</Table>
...
</smartTable>

In your controller you can use selectionChange method or simply:

var selectedRows = this.getView().byId('innerTable').getSelectedItems();