Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Get row ID from af:table with javascript

3265832Mar 7 2017 — edited Mar 29 2017

Hello, I have a table that has client listener. When I select a row from a table it triggers the JS code. Now, I'd like to fetch either row ID or a value from a selected row. I have so far put the table as client component and fetched it with var textfield = AdfAgent.AGENT.getElementById('pt1:r1:1:pc1:t2'); . Now I would need a way to find out the ID of the caller row or to manipulate cell from called row.

jDev version 12.2.1.2.

With regards,

Darko

Comments

ScottHagen

Hi, I've been trying to look into this and I think I've found a way to a partial solution to what you are looking for, at least for single selection.

I've gotten the selected row keys and index of the selected row.

Here is the javascript function, its a bit hacky in its implementation due to the seeming oddness of how the object returned by getSelectedRowKeys is

function jsSelectionListener(evt){

    var source = evt.getSource(); // javascript representation of the ADF table

    var selectedKeys = source.getSelectedRowKeys()  // object that holds all of the selected row keys

    var selectedRowKey;

   

    // Got to iterate through the selected keys to find the actual selected key

    for(var i = 0; i < source.getRows(); i++){

        if(selectedKeys[i] !== undefined)

            selectedRowKey = i;

    }

   

    if(selectedRowKey !== undefined){

        console.log(source.getRowIndex(selectedRowKey) + " " + selectedRowKey); // shows two numbers, one for the row's index and another for the rowKey, they aren't necessarily the same number.

    }

}

Its called through a client listener through an af:table

<af:clientListener type="selection" method="jsSelectionListener"/>

This method only gets a number, rather than an ID or value, so it isn't quite what you were asking for.

Here is docs I used if you'd like to look further.

AdfSelectionEvent

AdfRichTable

Hope this helps.

managed BEAN

Hello,

If i understand correctly then take a look at the attached application and run it.

You get a popup with dynamic client Id from button clicked in the table (the part of the path before the button id is the 'rownum' - that you want).

Regards,

Carlos

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 26 2017
Added on Mar 7 2017
2 comments
892 views