Skip to Content

How to read Value of a cell from sap.ui.table.Table?

Hi,

I want to get the value of a cell from a sap.ui.table, when I click on that cell. This cell is having 'Link' parameter; so, when I press on the link it's firing an event. In that evnt I should be able to get that value of that cell. Below is the code.

<Column width="auto" filterProperty="Owner" defaultFilterOperator="StartsWith">
	<m:Label text="{i18n>opOwner}"/>
	<template>
		<m:Link text="{tableModel>Owner}" press="handleLinkPress"/>
	</template>
</Column>
handleLinkPress : function(oEvent){
			
			var cell = "";

He in variable 'cell' I need to capture the Text of that cell.

I'm new in SAPUI5. Any help would be much appreciated. It would be very helpful if I can get the proper syntax.

Also, how to add date filter in date column.

<Column
	width="auto"
	filterProperty="Start_Date"
	defaultFilterOperator="StartsWith">
<m:Label text="{i18n>opstartdate}"/>
	<template>
		<m:Text text="{path: 'tableModel>Start_Date', type: 'sap.ui.model.type.Date', formatOptions: { pattern: 'dd/MM/yyyy' } }"/>
	</template>
</Column>
 

I've added the filter, but it's not working

Thanks,

Shubhrajit Chowdhury

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    Posted on Mar 15, 2017 at 07:40 AM
    handleLinkPress : function(oEvent){
    			
    			var cell = oEvent.getSource().getText();
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 15, 2017 at 07:01 AM

    There are a huge number of posts available that address this, please search the forums.

    Refer:

    How to read the data from selected SAPUI5 table row

    Understanding sap.ui.table.Table in 10 minutes,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 15, 2017 at 07:44 AM

    Hi Saurabh,

    Thanks for quick reply.

    The documents you've shared, it's more about selecting a Row and get the data. But I don't want to use Selectrow functionality. I want to read the Text of a selected "Cell".

    Here, if I click any of the value, I need to capture the Text. In this case it's 'admin5 sap'.

    Thanks,

    Shubhrajit


    temp.png (3.6 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 17, 2017 at 05:47 AM
    handleLinkPress = function(oEvent) {
    var oObject = oEvent.getSource().getBindingContext('tableModel').getObject(); // then you can do oObject.Owner }
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 08, 2018 at 09:14 AM

    Hi,

    i use "cellClick" event, fired when the user clicks a cell of the table.

    <table:Table selectionBehavior="RowOnly" rows="{ModelViaggi>/}" enableCellFilter="true" selectionMode="Single" visibleRowCount="7" ariaLabelledBy="title" id="TableViaggi" columnResize="columnResizeTableOrdini" columnMove="columnResizeTableOrdini" sort="sortTableOrdini" cellClick="cellClickTableViaggi">

    Then in the controller set:


    cellClickTableViaggi: function ( eve) {

    var object = eve.getParameters().rowBindingContext.getObject();

    ...

    }

    In this way i get data's row.
    You can try to get the information of the cell by "eve".

    Enjoy

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.