datagrid scrolling question

zryip theSlug zryip.theslug at gmail.com
Sun Aug 5 12:46:33 EDT 2018


A possible approach for updating only one row is described here:

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

You can add a special "update" row key for example in the dgData and if it
is true, execute the code of the mouseUp 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")
if (pDataArray["update"] is "true") then
 doMyTSNetQuery
end if
end FillInData

on mouseUp
   doMyTSNetQuery
end mouseUp

command doMyTSNetQuery
  doSomething
end doMyTSNetQuery

You are not sharing the code on how your are updating the result field. If
you are trying to put the result value directly in the field of each row by
considering the datagrid as a simple group of controls you are in the wrong
direction. Datagrid is a way to display data, so use the data to serve your
needs and you will be able to tame the beast. :)

For doing that use the FillInData handler. This will just send the message
to the datagrid to execute a doMyTSNetQuery message to the row.
And for changing the content of the result field of the second row for
example, use something like

SetDataOfLine 2, "update", true

and once finished, pass the value to false to stop the update.

Let me know if you could have the need of the following example:
A datagrid  with 8 rows containing a button, a result field. Plus a button
outside of the datagrid to query an update of one of the result field by
executing the code of one of the button. Do you have different scripts for
each button?


On Sun, Aug 5, 2018 at 5:21 PM, Brian Milby via use-livecode <
use-livecode at lists.runrev.com> wrote:

> You can get/put data from/into the grid one row at a time without needing
> to figure out the group name, so you could have it update in real time in
> your external button. You should be able to use the same behavior script
> (possibly with a slight modification) everywhere.
>
> I’m not at a computer right now so I will work out an example later if
> someone else doesn’t beat me to it.
>
> Thanks,
> Brian
> On Aug 5, 2018, 10:02 AM -0500, Douglas Ruisaard <dougr at telus.net>, wrote:
> > Thanks very much for the reply.
> > Good question .. made me think about why that won't work very well for
> me (but it would, of course, work).
> >
> > The button on each row not only queries the associated wi-fi module, but
> the "mouseUp" handler in the Behavior Script acquires a response back from
> each module. That message gets put into one of the fields in the row... so
> even if I didn't try to make a "mouseUp" call to within the row, I'd still
> want to populate each of the row's fields with the returning result...
> which would, of course, entail using the pseudo-group names again... *if* I
> wanted to display the returning information for each row "in real time"...
> which I do.
> >
> > There are two simple solutions, one of which I have done. Expand the
> grid to show all 8 rows and the scrolling issue disappears. Or ... as you
> suggest, "acquire" each row's data "outside" of the grid and then just
> display the complete set of data at once. Currently I do the former. Works
> very well on my big desktop monitor but not very "practical" to port to my
> iPad or Android... or any small display device.
> >
> > Another caveat is that each call to a wi-fi module take about 1 second
> to complete. This is a function of the module and what I am asking it to
> do... NOT an issue with "tsnet" (which is great!). So, taking the latter
> (your) approach, I'd lose the "real time" aspect and have to wait
> (#-of-modules * 1 second) before seeing any results. Currently that would
> be 8 seconds... not a *long* wait but annoying (in this age of microsecond
> responses). Expanding the project to more modules, obviously, increase the
> wait time... and I like the real-time display.
> >
> > However, this is as much a learning exercise as anything else... so I
> still would greatly appreciate if you or anyone could suggest an
> alternative methodology for issuing any sort of message to a datagrid, if
> there is one. Perhaps my method *is* the only one. THAT would be valuable
> information to have, as well.
> >
> > Douglas Ruisaard
> > Trilogy Software
> > (250) 573-3935
> >
> > From: Brian Milby [mailto:brian at milby7.com]
> > Subject: Re: datagrid scrolling question
> >
> > > My question is why use the button? Loop through the data in the grid
> and make the tsnet call manually for each line.
> > > If the button is calling a script outside of the DG, then you can use
> the same call.
> > > Then you don’t have to do any of those things to figure out the name
> of the row group.
> >
> _______________________________________________
> 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