Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

SAP UI5 Table. Selecting rows by selected index and manipulate controls in a cell within this row.

$
0
0

Hi,

 

I am using a sap UI5 Table and I am using oData model to populate the table.

 

On each row of this table, I have a textbox in one cell and a button in other cell which are disabled by default. My motive is to enable both textfield and button control in a row when user clicks on the same row and disable both when leaving the selected row. I am using session storage to store last selected index.

 

Code Snippet:

var oTable = sap.ui.getCore().byId("oTable"); //get Table object

var oRow = oTable.getRows()[oTable.getSelectedIndex()]; // get Row by selected index

var oTextField = oRow.getCells()[oTable.getColumns().length - 2]; // Disabled by default Text Field

var oButton = oRow.getCells()[oTable.getColumns().length - 1]; Disabled by default Button

 

// Enable controls for selected row

oTextField.setEnabled(true);

oTextField.setEditable(true);

oButton.setEnabled(true);

oTextField.focus();

 

My Issue is, since table has pagination, oTable.getRows() only gives me rows from 1st page of the table result. If I select row from 2nd page, the value of selected index gets out of bound for oTable.getRows()[selectedIndex] so I am not being able to manipulate disabled controls inside rows from 2nd page and beyond. Please help.

 

I have even tried to use jquery selector but I have not been able to select the selected row or <tr> as object Id for 1st <tr> on page 1 and 1st <tr> on page 2 is same. i.e. id="oTable-rows-row1"

 

Any Idea?

 

Thanks,

Aayush Shrestha


Viewing all articles
Browse latest Browse all 9165

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>