Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Select last row in grid

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658

    Select last row in grid

    Hello,

    I am looking to select the last row in a grid.

    Code:
    numRows = 0
    numRows = Lianja.Get("Page.Section").grid.rowcount
    Lianja.get("Page.Section").grid.goto(numRows)
    I even tried with LianjaDemo after selecting a customer with multiple orders:
    Code:
    Lianja.Get("Customers.section2").grid.goto(5)
    In either case, nothing seems to happen. I also tried using other methods such as last (as described in the wiki for the grid although it is not supposed to work if pagination is on)

    To make my situation is different, I am accessing a grid populated from a virtual table that is part of a tabview section.
    My grid is set to read-only although it has a double click event.

    Basically my goal is to select/highlight the last row of the grid regardless if pagination is on or not.

    Any suggestions on how to accomplish this?

    Thanks,
    Cory
    Last edited by CGibson; 2015-03-04 at 15:06.

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,223
    Hi Cory,

    I was thinking about combining Lianja.get().grid.doScroll(4) and a goto()

    However, it looks like it may not be working, so you may need to open a ticket.

    Herb

  3. #3
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    1,965
    Have you tried setting the grid .activerow property?

  4. #4
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    5,789
    Goto() positions on the record number not the row number. A grid row number and the record displayed in it are different things.

    When pagination is used then the whole concept of it is that you do not fill the whole grid up at once but rather it is done progressive as you navigate between pages. Therefore the last record in your resultset may not be in the grid.

    You should only use goto() for non paginated grids with a manageable number of rows.

    this is a trade off between usability and performance.
    Last edited by barrymavin; 2015-03-05 at 10:01.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Thank you for the feedback.

    Here is some added information.
    When the app is loaded, I want the grid to display the last entry made to the table (without having the user manually navigate to the last entry) and still allow the user to scroll through all previous entries. There could be 10, 100, or 1000+ entries.

    Would the following be a better usage?
    Code:
    // Move to the last data record. For paginated grids, move to the first record on the last page.
    Lianja.Get("Page.Section").grid.last()
    
    // Scroll to the bottom in case of pagination, 9 = bottom.
    Lianja.Get("Page.Section").grid.doscroll(9)
    Cory

  6. #6
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,223
    Hi Cory,

    Another idea might be to display your data in descending order.
    So the last entered record is always the first one in the grid.

    Herb

  7. #7
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Herb,

    That is how I am primarily handling it right now (I thought it would be easier that way) although there are still some issues.
    The problem with that is that two or more entries could be related and placed in sequential entries (separated into different entries because of the length of allowable text).
    Having it in descending order makes it harder to read.

    For example (although not the best example), the entry could be 'The boy ran from the wolf.'
    It may be saved in several entries.
    Decending order would be presented as:
    the wolf.
    ran from
    The boy

    Where as it's easier to read as (or to make associations in ascending order):
    The boy
    ran from
    the wolf.

    Cory

  8. #8
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hello,

    Using last() works as describe.
    Using doscroll(9) didn't seem to work for me.
    Using activerow doesn't seem to work since it appears to reset the row to 0 rather than the value provided.

    Any other suggestion on how to select or scroll down to the last record if the grid is paginated?

    Cory

  9. #9
    Senior Member
    Join Date
    Feb 2012
    Posts
    1,223
    Hi Cory,

    I suggest opening a ticket for doscroll(9).

    Herb

  10. #10
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,101
    Try this:
    Code:
    Lianja.Get("page1.section1").grid.last()
    do while recno('order_details')<reccount('order_details')
       Lianja.Get("page1.section1").grid.doscroll(1)
    enddo
    2794-last_row_in_grid_paginated.lpk
    This way you can select last row of last (paginated) page in grid.
    Not sure if there is some issue with grid in tabview. Some referencing effort is needed, I suppose.
    Last edited by josipradnik; 2015-03-06 at 09:16.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us