Hi Bob,

On Wed, Nov 13, 2019 at 9:59 AM Bob Miller via 4D_Tech <[email protected]>
wrote:

> The example in the docs doesn't help me understand what you mean about
> using Form with a listbox.
> Can you step through a little example of how Form would help in this case,
> to control a listbox?
>
Happy to try to help.
I recently posted a suggestion for replacing a pretty complex list form,
not a listbox, with a listbox and detail subform. It even has a picture.
https://forums.4d.com/Post/FR/32395457/1/32403208#32403208

I got a lot of useful ideas from the blog:
https://blog.4d.com/display-an-entity-selection-in-a-list-box/
https://blog.4d.com/display-a-collection-in-a-listbox/

A couple of tips I'll pass along that have emerged as being really helpful
for me:

- Think about whatever is in the listbox in terms of the actual data - not
in terms of rows and columns. When you want to select or edit something you
do it in the data and the listbox displays the results. This is almost
completely opposite the way you have done it for years.

- Whatever you are going to display in the listbox if you want to query,
hide, select some of the elements create two references to the data
(collection or entity selection). Something like:

Form.sourceCollection  //  this is the actual data

Form.listboxDisplay    //  this is what's displayed in the listbox

You set it up initially by assigning the source to the display:

Form.listboxDisplay:=Form.sourceCollection


Why is this a useful? Let's say I have a big list of names and I include a
search widget. I want to have the listbox show only the elements that match
the search condition. The collection.query() is wonderfully easy. It
returns either a collection (if you query a collection) or an entity
selection (if you query that). So
Form.listboxDisplay:=Form.sourceCollection.query(" name = :1 "; Get edited
text)
puts the result of the query in the listbox.

But this is memory inefficient - you may think. It's not because
Form.sourceCollection and Form.listboxDisplay are references to the data.
Totally different from arrays or selections. Creating multiple references
doesn't significantly increase the memory usage.

BTW - if you allow the user to make changes in the listbox using this
scheme because you are using a reference the changes in the listbox 'flow'
through to the sourceCollection. If you using an entity selection the
changes are made to the entity.


The bottom line is Form and ORDA represent a fundamentally different
approach to presenting data to the user. It's worth spending the time to
learn it. I can do things now with a few lines of code that used to require
multiple methods and dozens (hundreds) of lines of code to accomplish the
same effect.

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

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to