-
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
-
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
-
Have you tried setting the grid .activerow property?
-
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.
-
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
-
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
-
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
-
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
-
Hi Cory,
I suggest opening a ticket for doscroll(9).
Herb
-
1 Attachment(s)
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
Attachment 1038
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.