Forum Discussion

hrothrock's avatar
hrothrock
Contributor
5 years ago
Solved

lazy loading - objects not yet in memory

I am working with an application that uses lazy loading. In one of my tests, I am accessing a row that is visible on a normal monitor. Today I am working on my small laptop and the row is not only not visible, it is not even in memory because the app uses lazy loading to create the objects as they are needed. I can't find a way to scroll before finding the needed row (when I use several of the scroll methods for javascript I get a 'member not found' error. I can't define the row number and then scrollIntoViewIfNeeded because the row doesn't exist to find in the first place so it errors on that (panel(x) could not be found). Suggestions?

  • FindChild by itself still won't overcome the lazy-load... that's why my PseudoCode had the PageDown call in a while loop.  I'd re-write your code as follows.

     

    function findRow()
    {
    var Row = 8;
    var List = Aliases.pageDispatch.ListDispatchJobs;
    var child = List.FindChild("Name", "Panel(" + (Row -1) + ")", 1, true);
    while (!child.Exists) {
        List.Keys("[PageDown]");
        child = List.FindChild("Name", "Panel(" + (Row -1) + ")", 1, true);
    }
    Log.Message(child.contentText);
    }

    This will check to see if the child exists.  If not, it sends a page down keystroke to scroll the list and then checks again.  When it does exist, it exits the while loop and the child object is now the desired object.

9 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I'm assuming "Page Down" as a keystroke will work to navigate downward through the table, correct?  

     

    If so, here's what I would do (pseudocode)

     

    rowNotFound = true

    while (rowNotFound) {

        If (rowTextExistsOnScreen) {

           rowNotFound = false

        }

        else {

            tableObject.Keys('[Page Down]')

        }

     

    }

    • hrothrock's avatar
      hrothrock
      Contributor

      tristaanogre :

       

      Thanks for the reply. Here is what I was trying before:

       

      function GridCellCheckboxClick(List, Row, Column)
      {
         var Row = List.Panel(Row - 1).Panel(0);
         if (! (Row.Exists = true))

             {

                 Row.scrollIntoViewIfNeeded();

              }
      }

       

      Unnecessary parts of the function were removed. I knew I would need to clean up my if statement but because the row was not even in memory yet it was failing on the declaration of the variable, which is where I think your suggestion might also fail.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        My code was pseudcode, by no means fully fleshed out or tested. It was intended to present concept.

         

        So, basically, replace you "ScrollIntoView" with sending a PageDown keystroke to the table that needs to scroll.  Then write some code to check to see if the desired row is on screen.  FindChild works well for this.  It will return a stub object with Exists = false if not found or it will return an actual object which you can then return as the result of the function if so desired.