Adding entries to a long grid

I have a form with a grid. There are many records in the corresponding table, so the grid is scrollable. Records adding allowed in the table, so there is additional line for adding records in the bottom of the table. The inconvenience is that to add an entry, you have to scroll down a long list.

How it could be changed from the user viewpoint:

  • Move add entry line to the top of the table.
  • Scroll the table to the bottom automatically on form load.

What is easier (more reallistic) ?

Any solutions are considered, including those that require programming and source code modification.

Not aware of a way to put the new record row on the top. If the grid does not cover whole form, you could have a push button control to browse to the insert row (which is the special blank row at the end of the recordset). Otherwise, pick some other event and run LO Basic code to move cursor to the insert row. The overall structure will be something like the following (which is expanded here):

root_doc = ThisComponent
form_container = root_doc.Drawpage.Forms
main_form = form_container.getByName("MainForm")

main_form.last
main_form.moveToInsertRow()

Alternatively, you could use the UI to change over to add data only mode, although that could be confusing to user and I do not see a way to do it programmatically. The setting appears to be read only once the form is loaded.

(if this answers your question, pls accept the answer)

edit to add last command per comments

Thanks for the answer.
However there is a problem, that if list is longer than 47 entries, then it doesn’t show the rest entries and moveToInsertRow moves the cursor to the last shown entry, but not to the insert row. That makes it almost useless. Is there any way to fix it?

I will speculate that there are two issues here. First, I’m going to guess that the form property allow additions is set to no, which would prevent the insert row from working, or else there already is user-entered data in the insert row when you issue the command (which might create the appearance of going to last row). Second, the grid is not long enough to display all records at once, which could be changed by making the grid longer.

Please take a look at this little test case, it shows the issue.
Tested on Ubuntu 14.04 LO 4.2.7.2.

I stand corrected. It is going to the insert row before all rows are loaded, and then more rows are loaded so it no longer is the insert row. Looks like bug. Workaround: call this command before going to the insert row to force loading of entire recordset:

oEvent.Source.last

Thanks!
I’ve filled the bug report.