• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Can't get focus row working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't get focus row working

    It might be an easy one to fix here. I have an app that has quite a bit of records in a grid. When a user clicks a record, there is a new section shown in the app to work with that record. When they are done, the app fires an event called 'Back to main'. When that happens, I use an app var to refresh the grid. My users are complaining that when it refreshes, it takes them back to the top of the list. They want to go back to the spot they left. I thought I could do that with the focus row on the grid.
    My steps are to set an app var called 'rowNumberSelected', which works. I get a value in the NAB console that matches the row selected. for example 77. Then, when the back to main event fires, I use that app var to set another app var called 'focusRow'. That app var is linked to the grid in the focusRow property. I can see the app var getting set, but the grid refreshes, and it goes back to the top.
    How can I get the grid to go back to the same place?
    Thanks.

  • #2
    The reason is that the app variable used to focus the row is set, but the underlying data source is subsequently reloaded, which clears the focus.

    We will address this in the upcoming 6.3 update. However, if you don’t want to wait, you can add a startup/execute script that listens for the widget’s load event and then reapplies the focus-row app variable value if it has one.

    Of course, in my example I named the grid widget “myGrid” and the app variable “focusListRow”, so you’ll need to replace those with your actual widget and variable names.?
    Code:
    const myGrid = getWidget('myGrid');
    
    // When the grid loads, reset the focused row so it will refocus
    // on that row if the app variable has a value.
    //
    myGrid.getStore().on({
        load: function() {
            setTimeout(function() {
                setAppVar('focusListRow', getAppVar('focusListRow'));
            }, 150);
        }
    });

    Comment


    • #3
      Thanks, Johnny. The script is working.

      Comment

      Working...
      X