[DataGrid] replacing the values of a selected Line with new ones

Andre.Bisseret Andre.Bisseret at inria.fr
Mon Jul 13 10:44:32 EDT 2009


Bonjour,

In a dataGrid I need to change the values of a selected Line according  
to new data provided by the user (by mean of ask dialogs).

To get the current values of the line, I found in the docs the  
dgDataOfLine[theLine] property

So my handler (of a button) is the following :

  put the dgHilitedLines of group "dataGrid" into theLine
     put the dgDataOfLine[theLine] of group "dataGrid" into theDataA
     put the keys of theDataA into tKeys
     sort lines of tKeys numeric by word 2 of each --- because the  
keys are not in the same order as my column :
     REPEAT FOR each line tKey in tKeys
    put theDataA[tKey] & return after DataLine
END repeat

This works but

QUESTION 1: Is it possible to simplify this script ? and, could it be  
a simpler way to get the values of a line of the datagrid ? (I mean  
something like "get the dgTextOfLine[theLine] of group "dataGrid")

Then I do some calculations involving the old values (the lines of  
DataLine) and the new data (the answers of the user) in order to get  
the new values of the line .

Finally, I build a tab separated list of the new values in a variable  
newLine
and I send "deleteLines theLine" to group "dataGrid"
  and send "AddLine newLine" to group "dataGrid"

This works but

QUESTION 2 : is this the simpler way to repopulate the selected line ?  
or is it possible to directly change (or replace) the content of the  
selected line ? Again, my first idea would be something like set the  
dgTextOfLine[theLine]

I am learning the use of the dataGrid (that I like a lot :-)) and, in  
the same time, the use of arrays (that I do not like so much yet ;-)))

So any answer and help will be much appreciated

Best regards from Grenoble
André







More information about the use-livecode mailing list