What went wrong: I wanted a simple datagrid to store connection settings, the last column is named 'selected' and is either true or false. The datagrid has five rows and I want the setting of a row to true to set all the other rows to false i.e. only a single row may be set to true. To make things look better and easier to use I made the selected column a checkbox. My plan was to store a reference to the row that the user had set to true, then set all the values to false then set the row just being edited back to true. I placed the following in the column behavior for the column named 'selected':
Code: Select all
On mouseUp
-- call routine on the card params name of dg, row data, theline number I think
send "UpdateDG the dgControl of the target, the dgData of the target, the dgline of me" to card "dbsettings" in 0
end mouseUp
I now recognise that I should have used the dgindex of me rather than dgline of me. Anyway the routine UpdateDG does the following:
Code: Select all
On UpdateDG pDgName,pDataA, pRowNo
lock screen
# set all the values of selected to false
repeat for each key tkey in pDataA
put false into pDataA[tkey]["selected"]
end repeat
# set the row of interest to true
put true into pDataA[pRowNo]["selected"]
answer pDgName
set the dgData of pDgName to pDataA
unlock screen
end UpdateDG
Looking at the Datagrid documents I suspect that I may be guilty of editing the dgdata before the datagrid is ready. So where should I put my call?
Once I have made this post I intend trying to put the call to UpdateDg inside the On SelectionChanged in the group script of the datagrid. But as I really have no idea what I should be doing and have already managed to create self destructing code I thought I would ask how the experts would do it.
Sorry for a long post and thanks for reading,
best wishes
Simon K