I have found several examples on how to loop through an IG and get the selected rows.
I'm looking for a way to get the current selected row?
For example, if there are 5 rows and the user selects row number 3, I want to get the value of COL4 or ROW3. How do i do that?
Thanks in advance
Vinish Kapoor
Follow these steps:
Create a dynamic action on the interactive grid. Select the event Selection Change [Interactive Grid], then create a True action to execute JavaScript code and add the following code in it:
Change the EMPNO column to your column.
Change the P19_CURRENT_EMPID to any page item to see the result for testing.
vn
vn
I think I understand now...it will get the first selected row which would be the current row. Thanks again.
vn
Working code:
var model=apex.region("ig_gridName").widget().interactiveGrid("getViews", "grid").model;
var colName=model.getFieldKey("EMPNO"); -- Not required
console.log('Column name: ' + colName);
var cur_selected;
var selectedRecords=this.data.selectedRecords;
console.log('My Length: ' +selectedRecords.length );
-- make sure only one record is selected
if (selectedRecords.length == 1 ) {
var record = model.getRecord(selectedRecords[0]);
var i_empid = model.getValue( this.data.selectedRecords[0], "EMP_ID");
}
-- Set to Item
apex.item("P2_EMP_ID").setValue(i_empid);
Sivan
Hello, What could be a reason of this kind of error while trying to use your code.
error :-
Cannot read properties of undefined (reading '0').
Appreciate your explanation and help.