http://lessons.runrev.com/s/lessons/m/d ... d-contract
Works great on my laptop.
Doesn't work on Android. I know that it it registering when I click the button because it highlights the selected row...but doesn't expand it.
Here is the behaviorscript code I am using:
Code: Select all
-- This script defines the behavior of your data grid's custom template. This behavior
-- only applies to 'forms' and not 'tables'.
on CalculateFormattedHeight pDataArray
if pDataArray["expanded"] then
return 69
else
return 37
end if
end CalculateFormattedHeight
on FillInData pDataArray
set the text of field "firstname" of me to pDataArray["label 1"]
set the text of field "label" of me to pDataArray["label 2"]
set the label of btn "contact_email" of me to pDataArray["label 3"]
set the label of btn "webname" of me to pDataArray["label 4"]
set the label of btn "button_cell" of me to pDataArray["label 5"]
set the text of field "relationship" of me to pDataArray["label 6"]
set the text of field "company" of me to pDataArray["label 7"]
set the text of field "street" of me to pDataArray["label 8"]
set the text of field "city" of me to pDataArray["label 9"]
set the text of field "state" of me to pDataArray["label 10"]
set the text of field "zip" of me to pDataArray["label 11"]
if pDataArray["expanded"] is "" then
put false into pDataArray["expanded"]
end if
set the visible of graphic "ArrowExpanded" of me to pDataArray["expanded"]
set the visible of graphic "ArrowContracted" of me to not pDataArray["expanded"]
set the visible of btn "contact_email" of me to pDataArray["expanded"]
set the visible of btn "webname" of me to pDataArray["expanded"]
set the visible of btn "button_cell" of me to pDataArray["expanded"]
set the visible of field "relationship" of me to pDataArray["expanded"]
set the visible of field "company" of me to pDataArray["expanded"]
set the visible of field "street" of me to pDataArray["expanded"]
set the visible of field "city" of me to pDataArray["expanded"]
set the visible of field "state" of me to pDataArray["expanded"]
set the visible of field "zip" of me to pDataArray["expanded"]
put the text of field "firstname" of me into twhat
-- This eliminates the arrow on the last empty line
if twhat is "" or twhat is empty or twhat is " " then
set the visible of graphic "Arrowcontracted" of me to false
end if
end FillInData
on LayoutControl pControlRect
local theFieldRect
put item 1 of pControlRect into ttry
put the left of graphic "ArrowExpanded" of me into item 1 of theFieldRect
put the top of field "firstname" of me into item 2 of theFieldRect
set the left of field "firstname" of me to ttry + 25
put the formattedwidth of field "firstname" of me into tusewidth
set the left of field "Label" of me to ttry + 25 + tusewidth + 3
set the top of button "contact_email" of me to the bottom of field "firstname" of me + 15
set the left of button "contact_email" of me to ttry + 10
set the bottom of button "webname" of me to the bottom of button "contact_email" of me
set the left of button "webname" of me to the right of button "contact_email" of me + 10
set the left of button "button_cell" of me to the right of button "webname" of me + 10
set the bottom of button "button_cell" of me to the bottom of button "contact_email" of me
put the right of button "button_cell" of me + 10 into tright
put tright into item 3 of theFieldRect
set the top of field "street" of me to the bottom of button "contact_email" of me + 10
set the left of field "street" of me to ttry +10
set the left of field "city" of me to ttry + 10
set the top of field "city" of me to the bottom of field "street" of me
put the formattedwidth of field "city" of me into tusewidth2
set the bottom of field "state" of me to the bottom of field "city" of me
set the bottom of field "zip" of me to the bottom of field "city" of me
set the left of field "state" of me to ttry + 10 + tusewidth2 + 5
set the left of field "zip" of me to the right of field "state" of me + 5
set the top of field "relationship" of me to the bottom of field "state" of me + 10
set the left of field "relationship" of me to ttry + 10
set the bottom of field "company" of me to the bottom of field "relationship" of me
set the left of field "company" of me to the right of field "relationship" of me + 10
put the bottom of field "relationship" of me into tbottom
put tbottom into item 4 of theFieldRect
put the label of button "contact_email" of me into tone
if tone is "contact_email" or tone is "" then
set the vis of button "contact_email" of me to false
end if
put the label of button "webname" of me into ttwo
if ttwo is "webname" or ttwo is "" then
set the vis of button "webname" of me to false
end if
put the label of button "button_cell" of me into tthree
if tthree is "button_cell" or tthree is "" then
set the vis of button "button_cell" of me to false
end if
if the visible of field "relationship" of me then
put the bottom of field "relationship" of me + 10 into item 4 of theFieldRect
else
put the bottom of field "firstName" of me + 10 into item 4 of theFieldRect
end if
set the rect of graphic "Background" of me to theFieldRect
end LayoutControl
on ResetData
set the text of field "Label" of me to empty
end ResetData
on PreFillInData
-- Sent right before new data is going to replace existing data in the control
end PreFillInData
setprop dgHilite pBoolean
set the dgProp["hilited text color"] of the dgControl of me to "black"
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
getprop dgDataControl
-- Required by library so that it can locate your control.
return the long ID of me
end dgDataControl
on mouseDoubleUp pMouseBtnNum
local theKey
-- Example of how to edit the contents of a field.
-- By passing the index of the record associated with copy of this template being displayed and
-- a key (array key) the data grid will automatically save the changes the user
-- makes and refresh the UI by calling FillInData and resizeControl.
if pMouseBtnNum is 1 then
if the dgProps["allow editing"] of the dgControl of me then
switch the short name of the target
case "Label"
put "Label 1" into theKey
EditFieldText the long ID of the target, the dgIndex of me, theKey
break
end switch
end if
end if
pass mouseDoubleUp
end mouseDoubleUp
on mouseUp pMouseBtnNum
if pMouseBtnNum is 1 then
switch the short name of the target
case "ArrowExpanded"
case "ArrowContracted"
## Update internal data
SetDataOfIndex the dgIndex of me, "expanded", the short name of the target is "ArrowContracted"
## Redraw so LayoutControl and FillInData can update UI
RefreshIndex the dgIndex of me
break
end switch
end if
end mouseUp