Data Grid Question (Again!)
Posted: Thu May 30, 2013 2:50 pm
Okay, I have learned quite a bit about how DG's work, but am stumped here on this issue. Believe me, this is my last resort asking on the forum...I have read and looked everywhere. Here it goes... I am using the DG helper along with a single DG in my application. I am using the "Form" style of the DG. I have a few fields and buttons residing inside the DG template, one being a button that allows the user to add comments to a field. When each row is created, I am able to add unique comments each field inside each row, but when I navigate away from the card and come back, the field is blank. Each of the other rows data is still there, and I assume because the "fillInData" handler takes the array data and puts it back in its place when the DG is created each time. Now if I place a button OUTSIDE the row template and do something like this and then add the appropriate script to the behavior script, it works fine. (but obviously it populates all the rows with the same data, which I don't want).
The problem I have is adding data to the array when the data is being added from a handler from inside the behavior script. I will attach my behavior script so anyone can take a look. I hope I have been clear, if not please punch me in the head!
Code: Select all
on mouseUP
put fld "comments" into theDataA["comments"]
end mouseUp
Code: Select all
local vLine
on mouseDown
put the dgIndex of me into vLine
end mouseDown
on FillInData pDataArray
set the text of field "Label" of me to pDataArray["label 2"]
set the text of field "name" of me to pDataArray["name"]
set the text of field "commentField" of me to pDataArray["commentField"]
set the text of field "order" of me to pDataArray["order"]
set the text of field "total" of me to pDataArray["total"]
end FillInData
command EditValue
switch the short name of the target
case "Label"
EditFieldText the long id of field "Label" of me, the dgIndex of me,"label 2"
break
case "name"
EditFieldText the long id of field "name" of me, the dgIndex of me,"label 3"
break
case "commentField"
EditFieldText the long id of field "commentField" of me, the dgIndex of me,"label 4"
break
case "order"
EditFieldText the long id of field "order" of me, the dgIndex of me,"label 5"
break
case "total"
EditFieldText the long id of field "total" of me, the dgIndex of me,"label 8"
break
end switch
end EditValue
on mouseDoubleUp pMouseBtnNum
if pMouseBtnNum is 1 then
if (word 1 of the target is "field") then
if the dgProps["allow editing"] of the dgControl of me then
EditValue
exit mouseDoubleUp
end if
end if
end if
pass mouseDoubleUp
end mouseDoubleUp
on mouseUp pTheButton
if (pTheButton is 1) then
switch the short name of the target
case "Background"
break
//This is where I add the comments to the field but they are not retained when leaving the card
//I assume this data from "it" needs to be put into the array, but I cannot seem to figure this out...
//maybe I am just wrong all together in my thinking
case "comments"
ask "Enter any comments for your order" titled "Special Instructions"
put it into fld "commentField" of me
break
case "delete"
send "deleteindex vLine" to grp "DataGrid" in 1
break
end switch
end if
end mouseUp
on LayoutControl pControlRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
setprop dgHilite pBoolean
if pBoolean then
set the foregroundcolor of me to the dgProp["hilited text color"] of the dgControl of me
else
set the foregroundcolor of me to empty
end if
end dgHilite
-- Utility
getprop dgDataControl
-- Required by library so that it can locate your control.
return the long id of me
end dgDataControl