datagrid scrolling question

zryip theSlug zryip.theslug at gmail.com
Sun Aug 5 02:46:55 EDT 2018


Same remark than Mike, James and Jacque. When you have to change the value
of each row, populating the datagrid with a new data, seems to be the
better way to go.

Now for helping you with datagrids, I think you have to understand 2
importants concepts about datagrids:
- rows groups are created on the fly when you are scrolling the datagrid,
so they have no existence if you are not scrolling the datagrid (excepted
if the cache control option is activated, but this is another story). That
is explaining you have to scroll yourself the datagrid to be able to send
the click to the corresponding button
- the data displayed in the datagrid resides in an array named dgData. This
array is "multidimensional".
Basically the first key is representing the line, and the second key is
containing the values of the datagrid.
put "Row 1 First key value" into tDataA[1]["First key"]
put "Row 1 Second key value" into tDataA[1]["Second key"]
put "Row 2 First key value" into tDataA[1]["First key"]
put "Row 2 Second key value" into tDataA[1]["Second key"]

For a datagrid table we have an immediate graphical representation because
each keys are columns of the datagrid, and the fillindata handler located
in the default row script is doing the job for us of automatically populate
the column content.

First Key                                         Second key
Row 1 First key value                     Row 1 Second key value
Row 2 First key value                     Row 2 Second key value

For datagrid form with more than one value key, the developer must take
care himself of binding the key to one of the controls of the form
template. So we could potentially have a key by control if required (or
more than a key for a control. We will see the interest below).

on FillInData pDataArray

set the text of field "Label" of me to pDataArray["label 1"]

end FillInData

By default if you are populating the datagrid by using the inspector (or by
using the dgText property), the first key will be "label 1", the second
"label 2", etc. But if you are populating the datagrid by using the dgData
array, the keys used will be the keys you have defined for your dgData. So
in our example: "First key" and "Second key"

An example of script for your "one checkbox, three fields and two buttons"
template, might looks like:

on FillInData pDataArray
set the text of field "Label1" of me to pDataArray["label 1"]
set the text of field "Label2" of me to pDataArray["label 2"]
set the text of field "Label3" of me to pDataArray["label 3"]
set the hilited of btn "Checkbox1" of me to (pDataArray["check box state"]
is "true")
end FillInData

With a dgData looking like:
put "My label 1 row 1" into tData[1]["label 1"]
put "My label 2 row 1" into tData[1]["label 2"]
put "My label 3 row 1" into tData[1]["label 3"]
put "true" into tData[1]["check box state"]
put "My label 1 row 2" into tData[2]["label 1"]
put "My label 2 row 2" into tData[2]["label 2"]
put "My label 3 row 3" into tData[2]["label 3"]
put "false" into tData[2]["check box state"]
set the dgData of grp "myDataGrid" to tData

Now, for some purpose, such as interacting with the row controls, it could
be interesting to have additional keys inside the data. Not I'm thinking a
click in a button is required in your case. But you might have the need to
hide or to disable a button of a specific row on the fly by clicking a
button outside of the datagrid.

In this case
1. we are changing the data for the row by using the
 set the dgDataOfIndex property (see the datagrid documentation
http://lessons.livecode.com/m/datagrid/l/7315-how-do-i-update-data-in-a-row)
2. And when the data for the row is populated in the FillInData we might
have a specific key for disabling the button:

on FillInData pDataArray
set the text of field "Label1" of me to pDataArray["label 1"]
set the text of field "Label2" of me to pDataArray["label 2"]
set the text of field "Label3" of me to pDataArray["label 3"]
set the hilited of btn "Checkbox1" of me to (pDataArray["check box state"]
is "true")
set the enabled of btn "Action1" of me to (pDataArray["button enabled"] is
"true")
end FillInData


Hope these few examples might help you a bit to better understanding
datagrids.

On Sun, Aug 5, 2018 at 5:12 AM, J. Landman Gay via use-livecode <
use-livecode at lists.runrev.com> wrote:

> I was thinking the same thing. I think the critical distinction is that
> datagrids are primarily display mechanisms, not really intended to be read
> directly. It's much easier to parse the original input data than to try to
> traverse the grid itself, which uses some tricks to appear as a continuous
> single control.
>
> --
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> On August 4, 2018 6:54:21 PM James At The Hale via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
> I am a little lost here as to why this is a DG question as such.
>> Certainly being able to dynamically fill data within a row is a great UI
>> feature when the user is directly interacting with a row.
>> But it seems you wish to completely fill particular values in all the
>> rows from outside the DG.
>> In this case, why not operate directly on the DGdata, loop through the
>> array, fill in all the required values and then send the whole array back
>> to the DG?
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Zryip TheSlug
http://www.aslugontheroad.com



More information about the use-livecode mailing list