cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 xml view - Set unselect Row in m table

raza1997
Explorer
0 Kudos

Hi,

I am using m table with mode="MultiSelect".

I have input control in my table column and I able select the table row as soon as i enter any values. i used oTable.setSelectedItem(oTable.getItems()[index]); and it works fine.

oTable.setSelectedItem(oTable.getItems()[index]);

But i am not able to uncheck the checkbox from the selected row as soon as i remove value from input control.

oTable.removeSelections

oTable.removeSelections remove all the checkboxes but i need to remove only selected row.

please advise

View Entire Topic
leonikussmaul
Product and Topic Expert
Product and Topic Expert

Hi Raza,

The method setSelectedItem takes two parameters

1. oListItem -> the item which you want selected or unselected, which you are already passing

2. bSelect? -> whether it should be selected or deselected. The default value for this optional parameter is 'true', but if you pass false instead, it would deselect the item.

oTable.setSelectedItem(oTable.getItems()[index], false);
ramyachan24
Discoverer
0 Kudos

Hi Leoni,

I am using Ui Table and my selections are getting cleared after sorting the column. I saw your response to similar question. I tried the solution but still no luck. May I know in which event/method I need to implement your piece of code and can you please elaborate how to pass multiple selected rows. The method setSelectedIndices() is throwing an error saying that setSelectedIndices is not a method. Kindly help.

var oTable = this.getView().byId("Table"); 
var oRow = oTable.getRows()[1]; 
oTable.setSelectedIndex(oRow.getIndex());