[Solved] Code to invoke the table view in a form

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
debewerker
Posts: 13
Joined: Sat May 10, 2014 1:38 pm

[Solved] Code to invoke the table view in a form

Post by debewerker »

For forms displaying a single record i developed an easy to access search functionality.
Missing is code to switch on/off the table view (listview) at the top of the form (now set manually), see the screenshot below.
search.png
The interface is inspired by DataPerfect back in the 80's. With the cursor on a control one would hit a function key, say F3, and then
- an input field opens in the border of the form
- the recordset is sorted on the field bounded to the control
- a listview of 4-6 rows shows up
- upon each character entered, the recordpointer moves further downwards
- backspace cleares the input field, recordpointer moves to the first record
- ENTER terminates the search and formview is restored as before entering the search

(in fact DP was even more flexible, to each control an index (eg. more than one column) could be assigned, as well as a specification of the column sequence in the listview)

solutions / comments are welcome
Last edited by debewerker on Wed Dec 02, 2015 7:55 pm, edited 10 times in total.
OpenOffice 4.1.1 on LINUXmint quiana
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: code to invoke the table view in a form

Post by Villeroy »

Add a push button with Action="Open Document or URL" and URL= .uno:ViewFormAsGrid
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
debewerker
Posts: 13
Joined: Sat May 10, 2014 1:38 pm

Re: code to invoke the table view in a form

Post by debewerker »

dear Villeroy,

The answer given is not recognizable to me.
In formdesignmode with wizard switched to on, and putting a button on the form, no wizard guidance is given in my case (for a listbox the wizard is operational)
I found no match on ViewFormAsGrid in the API or developersguide.
From Andrew the max i can come up with is

Code: Select all

apropertyvalues(0).Name = "ActiveConnection"
apropertyvalues(0).Value = dbconnection
apropertyvalues(1).Name = "OpenMode"
apropertyvalues(1).Value = "open"
aPropertyValues(2).Name = "URL"
aPropertyValues(2).Value = ".uno:ViewFormAsGrid"     ' also tried   "ViewFormAsGrid"
oFormDocuments.loadComponentFromURL( sFormName ,"_blank",0,aPropertyValues())
However this does not give the desired effect.
Can you give a more detailed answer?
OpenOffice 4.1.1 on LINUXmint quiana
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Code to invoke the table view in a form

Post by B Marcelly »

Use the button properties.
Button that shows/hides the table as grid
Button that shows/hides the table as grid
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
debewerker
Posts: 13
Joined: Sat May 10, 2014 1:38 pm

Re: Code to invoke the table view in a form

Post by debewerker »

Thanks for propagating the suggestion of Villeroy.
By MRI of a button on the form, the targetURL property became visible (apparently different in functionality from the targetURL property in the com.sun.star.form.component.HTMLForm.)
Don't ask me how, but after hours with targetURL and developers guide and buttonItemListeners and Util, i stumbled upon:

Code: Select all

Dim oURL as new com.sun.star.util.URL
Dim oDispatcher as Object
Dim args(0) As New com.sun.star.beans.PropertyValue

oURL.Complete = ".uno:ViewFormAsGrid"
createUnoService( "com.sun.star.util.URLTransformer" ).parseStrict( oURL)
 
oDispatcher = oForm.getParent.getParent.CurrentController.Frame.queryDispatch( oURL, "",0 )
oDispatcher.dispatch( oURL,args() )
Apparently there is a dispatcher for forms/frames as well. (For writer documents the macro recorder simply introduces you to the dispatcher)
The dispatcher does toggle the last button of the navigation toolbar.
The elegance of this general search functionality is now complete: with one keystroke (F3), you can start typing the search term, and see the immediate (+/-) values adjacent to the searchstring
It allows to search numbers, strings, dates, and search in the displayed value of an associated listbox (be it by a workaround filtering the form, after three charaters are entered)
easy-access-search.odb
final result of this post, with sample dataset
(62.81 KiB) Downloaded 168 times
No idea how performance is with large recordsets. Without trials i guess that sorting the form is greatly enhanced if an index is present based on the column you want to search in. After sorting, the search is done by bisection.
OpenOffice 4.1.1 on LINUXmint quiana
Post Reply