cancel
Showing results for 
Search instead for 
Did you mean: 

Unselect Row in m table in sapui5

Former Member

I am using sap.m table. I am using followind coding...

<?xml version="1.0" encoding="UTF-8"?><Table items="{ztabledata>/results}" selectionBehavior="RowOnly" selectionChange="selectionChangeEditProfile" id="idEditProfileDetailsTable" mode="SingleSelectMaster"><columns><Column width="12em"><Text text="{i18n>LLMName}" /></Column><Column width="12em"><Text text="{i18n>LLMCode}" /></Column></columns><items><ColumnListItem><cells><Text text="{ztabledata>Lmname}" /><Text text="{ztabledata>Lmnode}" /></cells></ColumnListItem></items></Table>

maheshpalavalli
Active Contributor
0 Kudos

unselect means do you want to unselect it programatically or when you select a row again, you want to unselect the selected row?

Best Regards,
Mahesh

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member679019
Participant
0 Kudos

This solution is for the m.Table, not ui.table---


View:

Ensure your Table has itemPress defined

<Table itemPress="onItemPress">

Ensure your Table ColumnListItem tags have type defined

<ColumnListItem type="Active">


Controller:

onItemPress:function(oEvent){
	this.oLastSelection;
	var oCurrentSelection= oEvent.getSource().getSelectedItem();
	if(!this.oLastSelection){ //if it has no value
		this.oLastSelection= oCurrentSelection; //set it as the current selected item 
	} else if(this.oLastSelection===oCurrentSelection){ //else if its value is the same as the current selection
		oEvent.getSource().removeSelections(true); //remove selection
		this.oLastSelection= null; //reset last selected item
	} else{ //otherwise, set last selected item as current
		this.oLastSelection= oCurrentSelection;
	}
}
0 Kudos

use below Code, this will work for sure.

this.byId("idEditProfileDetailsTable").clearSelection();
former_member679019
Participant

clearSelection is only applicable to ui.table, for m.table you use removeSelections(true)

maheshpalavalli
Active Contributor
0 Kudos

use list mode : MultiSelect which will have unselect option

Best Regards,
Mahesh

former_member679019
Participant
0 Kudos

and if his requirement is to have singleSection only, what then will you do?