Leonard,

On Sun, Sep 10, 2017 at 8:30 PM, Leonard Soloniuk via 4D_Tech <
[email protected]> wrote:

> I realize that it is possible to:
>
​You're right. ​


> … but there seems that there would be a better way of doing this.

​As with many thing 4d - it depends. ​


> Any suggestions?
>
​I think subforms are really cool. I use them a lot but in fairly specific
ways. David has some fair criticisms ​of the lack of documentation
concerning them and I'd add a lack of guidance in thinking about how and
where to use them. So here are some of my takes on using them.

WRT the resizing issue - subforms are weak in this area but not crippled.
It depends on planning what the subform is going to do. For instance, one
purpose I really like subforms for is containing listboxes. Make a subform
with a listbox and some attendant buttons or other controls and you can
drop it into a form and have a completely modular object (the subform)
capable of displaying pretty much anything you want. Make the subform
object itself a c-obj (or text for v15) and the parent form can set the
subform object to a JSON of params for whatever you want the listbox to
display. That's pretty cool and sounds like something you are looking at
too.

How do you deal with the sizing issue? If you set the objects on the
subform to resize they will do that as the subform is resized.
Unfortunately they only respond to the resize event of the parent object.
So if you pull the parent object into a larger space on the parent form the
subform appears in its initial size. You've seen this. So you have can:

- include code to size the objects to the size of the parent object when
the form loads
- you can duplicate the subform in different sizes
- you can design the parent form on the small side

If you design the form small you can open it in a larger window and the
subform object resizes along with its objects.

I don't know if that's a bug or a feature honestly.

I think the docs and subform examples do a bit of disservice in the way
they present subform functionality and it put me off of them for a while as
well. I mean are they supposed to used for little date widgets or actual
useful stuff? And what am I supposed to do with the 'bound variable'? What
I've found is each of the uses they can be put to has its own architecture
and methodology and they don't overlap as much as you might think.

For instance I rarely put any code in the subform object so I don't use any
of the events for that object. I just don't find them useful very often
because I tend to use subforms as an extension of the parent form, in which
case I may just control the whole subform from the parent form either
directly or indirectly or because I've designed the subform to be more or
less independent of the parent form in which case it's pretty much self
sufficient.

It's easy to interact with subform objects directly from the parent form
using the Object get pointer command with the third param. In fact this can
lead to great portability and easy replication. A couple of years ago I did
a presentation showing how I use subforms on a scheduling form. Each 'trip'
(or appointment) on the schedule is setup in a subform duplicated from a
single template form. Then it's moved and resized to the appropriate place.
Un-needed objects are just set to invisible until needed again since you
can't delete duplicated objects.

Finally I'll put a plug in for managing the code on your forms and subform
using the 'form controller' approach I'm fond of. With the exception of
very simple forms I make a project method (eg. 'My_form_controller') and
put this method in pretty much every active object as well as the form
method. This sets up a central method that all form activity will channel
through. This makes it very convenient to manage form objects by their
names as well as to call form actions from other places. The save button
for instance. You can put verification or whatever code right in the button
itself. But what about trapping the Enter and return key? So you create a
save method and put that in each button. Nothing wrong with that but you
can wind up with a lot of related methods for the form and it can become
difficult to see them in one place. I just find it really helpful in
dealing with subforms. I've posted about this before if you want to see
more discussion of it.

-- 
Kirk Brooks
San Francisco, CA
=======================

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to