Ask Your Question
0

Base: replicate subform for each related element

asked 2018-08-28 10:59:21 +0100

belst gravatar image

updated 2018-08-28 11:39:34 +0100

Hi,

I currently have a schema with 3 tables:

+-----------+           +-------------+             +-----------+
| documents |           | groups      |             | positions |
+-----------+           +-------------+             +-----------+
| id        | <---+     | id          | <----+      | id        |
| name      |     |     | name        |      |      | name      |
+-----------+     +-----+ document_id |      +------+ group_id  |
                        +-------------+             +-----------+

Now I want to create a form for documents.

it should look a bit like this:


Nameinput: <input>

groupname1: <input>
table of positions

groupname2: <input>
table of positions

emptygroupname: <input>
empty table of positions


The empty group + table as last entry is to add a new group to the document.
If I add a new element, a new empty input + table should appear to add another one and so on.

Now I know I can use a tablecontrol for the positions and that would be fine, but how would I do it with the Groups?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-08-28 17:19:50 +0100

Ratslinger gravatar image

Hello,

Creating this form is simply the use of internal forms and sub forms. The main form is 'Documents' with a sub form to that of 'Groups' and then a sub sub form to that of 'Positions'. You final section of "emptygroupname" is not necessary because you can add new groups in the 'Groups' sub form any time.

Which controls you use is not a concern. Each can be comprised of individual controls or by using table controls (as used in the sample attached). The connection of Form->SubForm->SubSubForm is done through the internal form properties via the Link master fields and Link slave fields properties on the Data tab.

More information on Forms can be found in the LO documentation -> LibreOffice Base Handbook. See Chapter 4 - Forms.

Sample ----- Groups.odb

In this sample the is only one form. On that form when you select a Document it displays the Groups for that Document in the middle table control. When a particular Group is selected from a Document it displays, in the bottom table control, the Positions within the selected Group.

edit flag offensive delete link more

Comments

I think you did not understand my problem correctly.

I always want to see all positions and all groups in a form.

I know I can just use subgroups and then tablecontrols for all forms. but that does not give me the behaviour I want.

See here for a mockup:

https://ptpb.pw/h-AF.png

belst gravatar imagebelst ( 2018-08-29 09:55:41 +0100 )edit

If I understand you correctly, you are wanting to see ALL groups and ALL positions for any Document on a Form. Since this a varying amount of information from Document to Document, it would certainly require doing this through macros. The form would actually need creation at runtime since it is unknown what needs to be displayed until a actual Document is selected. A lot of work!

Ratslinger gravatar imageRatslinger ( 2018-08-29 16:15:45 +0100 )edit

This would be almost trivial with any good UI framework.

But it seems it is really hard to do in base :( I worked around it by adding a document_id field to the positions table and have groups and positions side by side. I need to add the group_id manually to the positions now though.

belst gravatar imagebelst ( 2018-08-30 09:32:38 +0100 )edit

@belst Could you please point me to one where this is trivial? Have worked with many and not seen this type of feature. With just a simple set of tables, this could result in thousands of controls on a single form making it impractical to work with.

Ratslinger gravatar imageRatslinger ( 2018-08-30 17:50:57 +0100 )edit

in qt, for example I'd create a widget which contains the subform and then instantiate it depending on the results of the query. probably less code than writing a macro to do it in base.

Sure it could create thousands of controls. in my case it would probably be maximum of 5 subforms.

But even then, that is nothing something like pagination or reuse of controls when they scroll out of the visible area (hard) could not fix.

belst gravatar imagebelst ( 2018-09-01 18:48:20 +0100 )edit

@belst Thank you for the response. Have dealt with QT before and, only my opinion, would hardly use the phrase 'almost trivial'. Your comment about creating a widget could also be done, in a manner, using Python. You can always go to QT if that is so much easier for you.

Ratslinger gravatar imageRatslinger ( 2018-09-01 19:45:52 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-28 10:59:21 +0100

Seen: 51 times

Last updated: Aug 28 '18