Skip to Content

Get sap.m.table row index depending on cell's search help selection

Hi,

I am using sap.m.table and have bound it to a template on edit button click. When user selects a specific cell, a search help ( manual entry is blocked) is opened [ values : A , B , C] and if he chooses "A", then value of cell changes to A on handleValueHelpClose function but I want to know the row of table that has been affected due to this value. Since it is a dynamic table, I know the cell id (oEvent.getSource().getId()) but how can I get the table row index ? Also I need to disable other columns of row if value is "A". What is the piece of code that can help me achieve this ?

Regards,

Janani

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 20, 2017 at 06:32 AM

    last char of id itself may be row index, that can be truncated out using substr(), if thats not helps,

    you can also get the row index by its binding context path as below:

    var sBindinPath = oEvent.getSource().getBindingContext().getPath();

    var index = sBindinPath.substr(sBindinPath.length - 1);

    And for disable/enable row can be achieved by one of the model property itself, as:

    oModel.setProperty(sBindinPath + "/bEnabled", false) ;

    and bind "bEnabled" to your desired column element like "<Input enabled="{bEnabled}" />

    hope this help.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 20, 2017 at 08:33 AM

    Hi Akhilesh,

    I tried a different route where I did not need sPath to be found and below is the step by step solution -

    1. Define rowCells as global variable.

    2. rowCells = this.getParent().getCells(); --> write it in valueHelpRequest function before you call fragment for select dialog

    3. In function where confirm/close logic is written (eg. __handleValueHelpClose), validate value of selected item is "A" then disable column fields of that row like this - rowCells[2].setEnabled(false) -> means 3rd column of that row is disabled

    Regards,

    Janani

    Add comment
    10|10000 characters needed characters exceeded