Selection Based ListBox - How do I extract and apply values to a single cell?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
Hi All

I feel like a rookie, but here is the deal...

I have used array Listboxes many times with success.  A current project requires the use of a Selection based listbox. How do I execute Cell level logic?  For example:  Let’s say I want to create a simple “fill down" function.  The user highlights several rows and right-clicks a one of the cells on the top row, then chooses “Fill down” from the menu presented using the command “Pop Up Menu”.  "ListBox Get Cell Position” command gives me the row and column plus a pointer to the field clicked on.  With all that information how do I get the value of the clicked on Cell (field) so I can stuff it in a variable and how do I walk down every row (record) in the highlighted selection and apply this value.  In an array Listbox it would be simple.  I am missing something in a Selection based Listbox...

I am sure I will slap my forehead and mutter the words, “that is so simple, why didn’t I think of it!!” when I hear the answer, but how do I reference a single cell (record/field) in a selection based listbox to either read values or to write values?

Thanks in advance for your help.

Kirk

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
Hi Kirk,
What version are you using?

If it's v16 or less think of the tasks you trying to accomplish in terms of
the selection in the listbox instead of the cells.
For the fill down example from the listbox you determine what field
(column) you are working with then apply the changes to that field of the
selection.
To select a record within the selection you use GOTO SELECTED RECORD.
https://doc.4d.com/4Dv18/4D/18/GOTO-SELECTED-RECORD.301-4504918.en.html
To make some change to a subset of the selection you use the set named in
the listbox config, make the edit and then restore the selection.
And so on.

If you are using v17+ I would strongly encourage you to start a brand new
form and use Form and an entity selection for the listbox instead. From
your question I can tell you are working with an unfamiliar mode of listbox
use. If you haven't started learning ORDA and its accompanying new
capabilities this sounds like an excellent application for them. The time
you spend learning to use ORDA will pay dividends moving forward. Learning
about selection based listboxes is only useful if you are working on an old
project that requires them.

On Tue, Nov 12, 2019 at 12:22 AM rooftop99--- via 4D_Tech <
[hidden email]> wrote:

> Hi All
>
> I feel like a rookie, but here is the deal...
>
> I have used array Listboxes many times with success.  A current project
> requires the use of a Selection based listbox. How do I execute Cell level
> logic?  For example:  Let’s say I want to create a simple “fill down"
> function.  The user highlights several rows and right-clicks a one of the
> cells on the top row, then chooses “Fill down” from the menu presented
> using the command “Pop Up Menu”.  "ListBox Get Cell Position” command gives
> me the row and column plus a pointer to the field clicked on.  With all
> that information how do I get the value of the clicked on Cell (field) so I
> can stuff it in a variable and how do I walk down every row (record) in the
> highlighted selection and apply this value.  In an array Listbox it would
> be simple.  I am missing something in a Selection based Listbox...
>
> I am sure I will slap my forehead and mutter the words, “that is so
> simple, why didn’t I think of it!!” when I hear the answer, but how do I
> reference a single cell (record/field) in a selection based listbox to
> either read values or to write values?
>
> Thanks in advance for your help.
>
> Kirk
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************



--
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:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
In reply to this post by 4D Tech mailing list

> Le 12 nov. 2019 à 09:22, rooftop99--- via 4D_Tech <[hidden email]> a écrit :
>
> Hi All
>
> I feel like a rookie, but here is the deal...
>
> I have used array Listboxes many times with success.  A current project requires the use of a Selection based listbox. How do I execute Cell level logic?  For example:  Let’s say I want to create a simple “fill down" function.  The user highlights several rows and right-clicks a one of the cells on the top row, then chooses “Fill down” from the menu presented using the command “Pop Up Menu”.  "ListBox Get Cell Position” command gives me the row and column plus a pointer to the field clicked on.  With all that information how do I get the value of the clicked on Cell (field) so I can stuff it in a variable and how do I walk down every row (record) in the highlighted selection and apply this value.

Hi,
schematically, I do this:
  save selection
  use userset
  selection to array
  replace values in array
  array to selection
  use selection
  highlight userset

--
Arnaud de Montard




**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list

> Hi,
> schematically, I do this:
>   save selection
>//  use userset

use listbox selected set
maybe simpler
apply to selection(<field> = <value>)

>//   selection to array
>//   replace values in array
>//   array to selection

>   use selection
>   highlight userset
>
> --
> Arnaud de Montard
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************
We have done so much, with so little, for so long;
We are now qualified to anything with nothing <sigh>
  - unknown
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Thank you Kirk!  That got me past my mental block!!  We are on 16, but will be moving to 17 in a month or two.  Due to timing I will have to build this feature the old way, but once we get to 17 I will certainly dive into ORDA.

Kirk


> On Nov 12, 2019, at 7:10 AM, Kirk Brooks via 4D_Tech <[hidden email]> wrote:
>
> Hi Kirk,
> What version are you using?
>
> If it's v16 or less think of the tasks you trying to accomplish in terms of
> the selection in the listbox instead of the cells.
> For the fill down example from the listbox you determine what field
> (column) you are working with then apply the changes to that field of the
> selection.
> To select a record within the selection you use GOTO SELECTED RECORD.
> https://doc.4d.com/4Dv18/4D/18/GOTO-SELECTED-RECORD.301-4504918.en.html
> To make some change to a subset of the selection you use the set named in
> the listbox config, make the edit and then restore the selection.
> And so on.
>
> If you are using v17+ I would strongly encourage you to start a brand new
> form and use Form and an entity selection for the listbox instead. From
> your question I can tell you are working with an unfamiliar mode of listbox
> use. If you haven't started learning ORDA and its accompanying new
> capabilities this sounds like an excellent application for them. The time
> you spend learning to use ORDA will pay dividends moving forward. Learning
> about selection based listboxes is only useful if you are working on an old
> project that requires them.
>
> On Tue, Nov 12, 2019 at 12:22 AM rooftop99--- via 4D_Tech <
> [hidden email]> wrote:
>
>> Hi All
>>
>> I feel like a rookie, but here is the deal...
>>
>> I have used array Listboxes many times with success.  A current project
>> requires the use of a Selection based listbox. How do I execute Cell level
>> logic?  For example:  Let’s say I want to create a simple “fill down"
>> function.  The user highlights several rows and right-clicks a one of the
>> cells on the top row, then chooses “Fill down” from the menu presented
>> using the command “Pop Up Menu”.  "ListBox Get Cell Position” command gives
>> me the row and column plus a pointer to the field clicked on.  With all
>> that information how do I get the value of the clicked on Cell (field) so I
>> can stuff it in a variable and how do I walk down every row (record) in the
>> highlighted selection and apply this value.  In an array Listbox it would
>> be simple.  I am missing something in a Selection based Listbox...
>>
>> I am sure I will slap my forehead and mutter the words, “that is so
>> simple, why didn’t I think of it!!” when I hear the answer, but how do I
>> reference a single cell (record/field) in a selection based listbox to
>> either read values or to write values?
>>
>> Thanks in advance for your help.
>>
>> Kirk
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:[hidden email]
>> **********************************************************************
>
>
>
> --
> 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:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
I now get selection based ListBoxes…  Thanks for your help!!

Kirk

> On Nov 12, 2019, at 9:09 AM, Chip Scheide via 4D_Tech <[hidden email]> wrote:
>
>>
>> Hi,
>> schematically, I do this:
>>  save selection
>> //  use userset
>
> use listbox selected set
> maybe simpler
> apply to selection(<field> = <value>)
>
>> //   selection to array
>> //   replace values in array
>> //   array to selection
>
>>  use selection
>>  highlight userset
>>
>> --
>> Arnaud de Montard
>>
>>
>>
>>
>> **********************************************************************
>> 4D Internet Users Group (4D iNUG)
>> Archive:  http://lists.4d.com/archives.html
>> Options: https://lists.4d.com/mailman/options/4d_tech
>> Unsub:  mailto:[hidden email]
>> **********************************************************************
> We have done so much, with so little, for so long;
> We are now qualified to anything with nothing <sigh>
>  - unknown
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html <http://lists.4d.com/archives.html>
> Options: https://lists.4d.com/mailman/options/4d_tech <https://lists.4d.com/mailman/options/4d_tech>
> Unsub:  mailto:[hidden email] <mailto:[hidden email]>
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
RE> If you are using v17+ I would strongly encourage you to start a brand new form and use Form and an entity selection for the listbox instead. From

This inspired me to look up the documentation for the 'Form' commend (https://doc.4d.com/4Dv18/4D/18/Form.301-4505774.en.html) - but I found the explanation very unsatisfactory.  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?

Thanks -

Bob Miller
Parker Hannifin Corp.
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
also - formatting of the displayed data in the listbox (including
column widths and titles)


Thanks
Chip
On Wed, 13 Nov 2019 17:59:41 +0000, Bob Miller via 4D_Tech wrote:
>
> Can you step through a little example of how Form would help in this
> case, to control a listbox?
We have done so much, with so little, for so long;
We are now qualified to anything with nothing <sigh>
  - unknown
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Selection Based ListBox - How do I extract and apply values to a single cell?

4D Tech mailing list
In reply to this post by 4D Tech mailing list
Hi Bob,

On Wed, Nov 13, 2019 at 9:59 AM Bob Miller via 4D_Tech <[hidden email]>
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:[hidden email]
**********************************************************************