cancel
Showing results for 
Search instead for 
Did you mean: 

smart table press on column and change view

truckla
Explorer
0 Kudos

hi!

I have connected a smarttable via cds and odata and now I want to click on an entry in the smarttable so that a new view opens.
However, I do not know how to get the data.
I have found this here: https://answers.sap.com/questions/12946842/how-to-get-selected-item-from-a-smart-table-in-a-f.html

onButtonPress: function (oEvent) {
  var oSource = oEvent.getSource();
  var oContext = oSource.getParent().getParent().getTable().getSelectedContexts(); 
evt.getSource().getParent().getParent().getSelectedItems();

But I don't know where to use this code.

I still don't understand how I make a selection that opens a new view. How do I get the click on a cell and trigger something that opens a view?

lenastodal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Kombalu,

Thank you for visiting SAP Community to get answers to your questions. I am here to help you to get the most out of it.

First of all, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't done so already), as it provides tips for preparing questions that draw responses from our members.
Please also make sure you're using all appropriate tags, so the right experts can find your question. Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question - but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Best,
Lena (SAP Community Moderator)

Accepted Solutions (1)

Accepted Solutions (1)

MioYasutake
Active Contributor
0 Kudos

Hi truckla,

First you need to enable row selection on the SmartTable.

To do that, configure the internal table inside the SmartTable as below (assuming that you have selected ResponsiveTable as tableType).

<smartTable:SmartTable ...> 
	<Table>
		<ColumnListItem type="Navigation" press="onItemPress">
		</ColumnListItem>
	</Table>						
</smartTable:SmartTable>

This enables the SmartTable to show a small arrow on the far right.

Second, implement onItemPress method to trigger navigation.

onItemPress: function (oEvent) {
	var id = oEvent.getSource().getBindingContext().getProperty("ProductID");
	this.getOwnerComponent().getRouter().navTo("Detail", {
		id: id
	});
}

You can find more information about Routing and Navigation in blow document.

https://openui5.hana.ondemand.com/topic/2366345a94f64ec1a80f9d9ce50a59ef

Regards,

Mio

Answers (0)