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 FillInData pDataArray
-- This message is sent when the Data Grid needs to populate
-- this template with the data from a record. pDataArray is an
-- an array containing the records data.
-- You do not need to resize any of your template's controls in
-- this message. All resizing should be handled in resizeControl.
set the text of field "City" of me to pDataArray["label 1"]
set the text of field "State" of me to pDataArray["label 2"]
put pDataArray["label 3"] into tDate
set itemdel to "-"
## Re-arrange to normal english (non SQL) date order:
put item 2 of tDate & "/" & item 3 of tDate & "/" & item 1 of tDate into tNewDate
## Now use LCs convert command:
convert tNewDate to long date
## Now you can display the converted date:
put tNewDate into field "Begins" of me
set the text of field "Title" of me to pDataArray["label 4"]
set the text of field "Lane" of me to pDataArray["label 5"]
set the text of field "Street" of me to pDataArray["label 6"]
set the text of field "Link" of me to pDataArray["label 7"]
set the text of field "Phone" of me to pDataArray["label 8"]
set the text of field "Zipcode" of me to pDataArray["label 9"]
set the text of field "Description" of me to pDataArray["label 11"]
put pDataArray["label 12"] into cCat
put cCat into tFileName
put "http://www.bowlingquest.com/wp-content/plugins/my-calendar/icons" into tFullPath
put tFullPath &"/"& tFileName into tFullPath
set the filename of image "image" of me to tFullPath
end FillInData
on LayoutControl pControlRect
local theFieldRect
-- This message is sent when you should layout your template's controls.
-- This is where you resize the 'Background' graphic, resize fields and
-- position objects.
-- For fixed height data grid forms you can use items 1 through 4 of pControlRect as
-- boundaries for laying out your controls.
-- For variable height data grid forms you can use items 1 through 3 of pControlRect as
-- boundaries, expanding the height of your control as needed.
-- Example:
put the rect of field "City" of me into theFieldRect
put item 3 of pControlRect - 5 into item 3 of theFieldRect
set the rect of field "City" of me to theFieldRect
set the rect of graphic "Background" of me to pControlRect
end LayoutControl
on ResetData
-- Sent when data is being emptied because the control is no longer being used to display data
-- set the text of field "Label 1" of me to empty
-- set the text of field "Label 2" of me to empty
-- et the text of field "Label 3" of me to empty
-- set the text of field "Label 4" of me to empty
-- set the text of field "Label 5" 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
-- This custom property is set when the highlight of your custom template has
-- changed. By default the "Background" graphic will be highlighted for you.
-- You only add script here if you want to further customize the highlight.
-- Example:
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