I begun working on livecode a couple of weeks ago with very very little programming experience (self taught some ruby, lasted a couple of months).
I'm trying to familiarize with the data grid. I succeeded in creating a few controls to populate a DG table, however I can't find a way to edit a single row.
What I wanted to do is create a few fields that could either add a line or edit the one selected:
so I used this code on the card script:
Code: Select all
on addLine callType
if callType = "add" then
put the dgNumberOfLines of group "Capitoli" + 1 into capLines
else if callType = "edit" then
put the dgHilitedLines of group "Capitoli" into capLines
end if
put field "FDCapitolo" into arrayCap[ "Capitolo" ]
put field "FDNome" into arrayCap["Nome"]
put field "FDRef" into arrayCap["Ref"]
dispatch "AddData" to group "Capitoli" with arrayCap, capLines
dispatch "ScrollLineIntoView" to group "Capitoli" with capLines
end addLine
Adding a line works properly, however dispatching "AddData" with a line that's already populated only creates a new line instead of editing the selected one. I read the API and this seems to be the correct behaviour. Can't seem to find the right command though, could you please help me a bit? I've got two questions...
1) Could you please help me in dispatching the correct command to edit a line?
2) If the AddData does not overwrite a line, why do I need to provide the command with a line number?
Thanks a million!
Cheers
Michael