Setting focus to a previously selected row in IG after Page Submit

血红的双手。 提交于 2019-12-11 06:36:54

问题


Here is basically how it looks:

Whenever I select one of the rows on the Interactive Grid on the left, a "Selection Change [Interactive Grid]" dynamic action triggers and loads some information on the Interactive Grid on the right side.

I can add new rows on it, and I'd like that, after I click on "Save" (not shown on the picture, but it's a bit above the "Copy" button), a dynamic action triggers on Page Load and selects the row on the left Interactive Grid that was previously focused.

I found the ".closest(selector)" function to try and attempted it, like this:

$(".getRowId").on('click',function()
        {
            var currentRow = $(this).closest('tr');
            alert(currentRow.attr('id'));
        }
                     );

The function that I'm using on Page Load is:

$(document).ready(function()
    {
        $(currentRow(id)).focus();    
    }
                 );

The function ".getRowId" is inside a "Selection Change [Interactive Grid]" function, so I'm wondering if that's why it doesn't work. Should I have that function on a "On Click" DA in order for it work?


回答1:


I did not quite understand why do you need to submit the page, I would try using the default button to save (insert and update) the interactive grids. This button does not submit the page and preserves the selected values.


If do you need to submit the page, I think your solution will look like this:

1 - Create a dynamic action on "selection change (interactive grid)"

The true action is "execute javascript code"

//set the static id field on your interactive grid and put the value on gridID variable
var gridID = "dept";
var ig$ = apex.region(gridID).widget();
var grid = ig$.interactiveGrid("getViews","grid");
var selectedRecord = grid.getSelectedRecords();
console.log(selectedRecord);
localStorage.setItem('lastSelectedRecord', JSON.stringify(selectedRecord));

2 - Create a dynamic action on "page load"

The true action is "execute javascript code"

//set the static id field on your interactive grid and put the value on gridID variable
var gridID = "dept";
var ig$ = apex.region(gridID).widget();
var grid = ig$.interactiveGrid("getViews","grid");

grid.setSelectedRecords(JSON.parse(localStorage.getItem('lastSelectedRecord')));

Test here https://apex.oracle.com/pls/apex/f?p=150297:35 click on "Save22" button



来源:https://stackoverflow.com/questions/53061135/setting-focus-to-a-previously-selected-row-in-ig-after-page-submit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!