sample data grid code?

sadhu at sadhu at
Sat Apr 11 12:49:06 EDT 2009


Thank you again for your help, which is invaluable.  I am not sure where
else I could find commands like "scrollLineIntoView"?  Very appreciated.

I was able to apply much of your example code.  And this leads me to the
next question, since you are being so kind with examples.

The code (and data grids in general) are seemingly line oriented, as far
as I can tell.  I want to be able to change one cell at a time.  I came up
with some code that works, but frankly it's pretty ugly.  Is there a
command like "modifyCell" ?

Here below is some code, it takes a line out of the data grid, puts it
into an array, deletes the original line in the grid, modifies one element
in the array, then converts the array back to a form suitable for
"addLine", and then puts it back into the data grid in place of the
deleted line.  It would be cleaner if this could all be done in place, ie,
right in the data grid itself.  The data grid has 9 columns so hard coding
every one is clumsy too.

Perhaps you can suggest improvements to this? If not, no problem, I can
make this method work. And again, I am very grateful for your patience
with me as a novice.


(code snippet)

         put "col 1" & cr  into columset
         put "col 2" & cr after columset
         put "col 3" & cr after columset
         put "col 4" & cr after columset
         put "col 5" & cr after columset
         put "col 6" & cr after columset
         put "col 7" & cr after columset
         put "col 8" & cr after columset
         put "col 9"  &cr after columset

         get the dgdataofline[3] of group "data grid 1" of card "data grid
         put it into theA
         dispatch "ScrollLineIntoView" to group "Data Grid 1" of card
"data grid card" with 3
         dispatch "deleteLine" to group "Data Grid 1" of card "data grid
card" with 3
         put "foobar" into theA["col 3"]
         put      theA["col 1"] & tab \
                & theA["col 2"] & tab \
                & theA["col 3"] & tab \
                & theA["col 4"] & tab \
                & theA["col 5"] & tab \
                & theA["col 6"] & tab \
                & theA["col 7"] & tab \
                & theA["col 8"] & tab \
                & theA["col 9"] into thePText

         dispatch "AddLine"  to group "data grid 1" of card "data grid
card" with thePText, columset, 3

More information about the use-livecode mailing list