最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Setting focus to a previously selected row in IG after Page Submit - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question asked Oct 30, 2018 at 9:30 AWildmannAWildmann 1891 gold badge4 silver badges22 bronze badges 3
  • When do you click in this button "Save", something more is executed? or just the process to save your interactive grid? If is only the process of your interactive grid, why are you submitting the page? The default button "Save" of the interactive grid don't submit the page and preserves selected values. Look at this page apex.oracle./pls/apex/f?p=150297:35 the "Save" is a default button. "Save22" is a custom button that submit the page. – romeuBraga Commented Oct 30, 2018 at 14:23
  • This link is from a sample application. They remend disabling this default save button and using this custom button. But as you see, the default save button works and saves changes to the two interactive grids ... – romeuBraga Commented Oct 30, 2018 at 14:33
  • The current Save button I have submits the page to run either an Insert or Update PL/SQL Process. I'm trying to find a way to save that selected row from the left, and automatically have it selected when the page loads again after the submit. I'm also trying a couple of other ideas, such as using a "getSelectedRecords" function, but I just won't save these selected rows to use the "setSelectedRecords" when the page is loaded again. – AWildmann Commented Oct 30, 2018 at 14:54
Add a ment  | 

1 Answer 1

Reset to default 5

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./pls/apex/f?p=150297:35 click on "Save22" button

发布评论

评论列表(0)

  1. 暂无评论