Data Grid syntax question
Posted: Wed May 22, 2013 3:04 pm
I'm having issues deleting a line in a data grid when the code is placed within the "Delete" button of the row of the DG. If I place a button outside of the DG and place the code, it works fine....(I understand for the most part that you have to refer to the "dgControl of me" when referring to a particular button that resides within a row template, but I can't seem to figure out the best syntax for accomplishing this. I will provide the code in the behavior script to show what I am doing. Below is a picture of a row for illustration purposes.
--THIS IS WHERE I HAVE MY SCRIPT THAT IS CAUSING ISSUES--
case "Delete"
dispatch "deleteIndex" to grp "DataGrid" card "total" of me with vLine
break
[img]
http://forums.runrev.com/download/file. ... ew&id=2003
[/img]
Code: Select all
## Behavior script generated by the DataGrid Helper's Script Builder
## 5/20/13 - 10:57 PM
global vLine
on FillInData pDataArray
if (pDataArray["label 1"] is a color) then
set the backcolor of graphic "Background" of me to pDataArray["label 1"]
end if
set the text of field "orderItem" of me to pDataArray["orderItem"]
set the text of field "OrderInfo" of me to pDataArray["OrderInfo"]
set the text of field "total" of me to pDataArray["total"]
set the visible of button "Edit Order" of me to (pDataArray["label 2"] is not false)
end FillInData
command EditValue
switch the short name of the target
case "orderItem"
EditFieldText the long id of field "orderItem" of me, the dgIndex of me,"orderItem"
break
case "OrderInfo"
EditFieldText the long id of field "OrderInfo" of me, the dgIndex of me,"OrderInfo"
break
case "total"
EditFieldText the long id of field "total" of me, the dgIndex of me,"total"
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
case "Edit Order"
answer "Add your action here"
break
case "Special Instructions"
answer "Add your action here"
break
--THIS IS WHERE I HAVE MY SCRIPT THAT IS CAUSING ISSUES--
case "Delete"
dispatch "deleteIndex" to grp "DataGrid" card "total" of me with vLine
break
end switch
end if
end mouseUp
on LayoutControl pControlRect
set the rect of graphic "Background" of me to pControlRect
set the left of fld "total" of me to the left of btn "Edit Order" of me
set the right of btn "Edit Order" of me to item 3 of pControlRect - 30
put the left of btn "Edit Order" of me into theLeft
put the rect of fld "OrderInfo" of me into theRect
put theLeft -10 into item 3 of theRect
set the rect of fld "OrderInfo" of me to theRect
put the rect of fld "orderItem" of me into theRect
put theLeft -10 into item 3 of theRect
set the rect of fld "orderItem" of me to theRect
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
on mouseDown
put the dgLine of me into vLine
end mouseDown
case "Delete"
dispatch "deleteIndex" to grp "DataGrid" card "total" of me with vLine
break
[img]
http://forums.runrev.com/download/file. ... ew&id=2003
[/img]