Datagrid form, resizable, multiple fields, click problem
Posted: Thu Sep 13, 2012 7:28 pm
I have succeeded in setting up a datagrid form, getting data to multiple fields in it, and making it resizable. For me, that's pretty good.
Now, the last step is to be able to click on a specific line in the datagrid to go to the next card.
Seems easy..BUT...when I set up the object script, it will only fire when you click on the Rect that was put into pcontrolRect for resizing. I have tried to put other Rects into pcontrolRect, but have failed.
I have tried putting everything in one Rect, but then it won't resize...
So...I need help please. Here is the code that works for resizability - but it only recognizes a click when you click on theFieldRect (which is my field col3)
Here is the object script for the datagrid
Now, the last step is to be able to click on a specific line in the datagrid to go to the next card.
Seems easy..BUT...when I set up the object script, it will only fire when you click on the Rect that was put into pcontrolRect for resizing. I have tried to put other Rects into pcontrolRect, but have failed.
I have tried putting everything in one Rect, but then it won't resize...
So...I need help please. Here is the code that works for resizability - but it only recognizes a click when you click on theFieldRect (which is my field col3)
Code: Select all
on LayoutControl pControlRect
local theFieldRect
## label new field
put the rect of field "label" of me into theFieldRect2
put item 3 of pControlRect - 5 into item 3 of theFieldRect2
set the rect of field "label" of me to theFieldRect2
##resizes field to fit content
put item 2 of thefieldRect2 + the formattedheight of field "label" of me - the bottommargin of field "label" of me into item 4 of theFieldRect2
set the rect of field "label" of me to thefieldRect2
## new field webname
put the rect of field "webname" of me into theFieldRect3
put item 2 of pControlRect +1 into item 2 of theFieldRect3
put item 3 of pControlRect -5 into item 3 of theFieldRect3
set the rect of field "webname" of me to theFieldRect3
##resizes field to fit content
put item 2 of thefieldRect3 + the formattedheight of field "webname" of me - the bottommargin of field "webname" of me into item 4 of theFieldRect3
set the rect of field "webname" of me to thefieldRect3
## new field date_added
set the top of field "date_added" of me to the bottom of field "date_added" of me
put the rect of field "date_added" of me into theFieldRect4
put item 2 of pControlRect +15 into item 2 of theFieldRect4
put item 3 of pControlRect -5 into item 3 of theFieldRect4
set the rect of field "date_added" of me to theFieldRect4
##resizes field to fit content
put item 2 of thefieldRect4 + the formattedheight of field "date_added" of me - the bottommargin of field "date_added" of me into item 4 of theFieldRect4
set the rect of field "date_added" of me to thefieldRect4
## original field col3 expands field to fill width
set the top of field "col3" of me to the bottom of field "label" of me +10
put the rect of field "Col3" of me into theFieldRect
put item 3 of pControlRect - 5 into item 3 of theFieldRect
set the rect of field "col3" of me to theFieldRect
##resizes field to fit content
put item 2 of thefieldRect + the formattedheight of field "col3" of me - the bottommargin of field "col3" of me into item 4 of theFieldRect
set the rect of field "col3" of me to thefieldRect
##update the bounding rect....
put item 4 of theFieldRect into item 4 of pControlRect
set the rect of graphic "background" of me to pControlRect
end LayoutControl
Code: Select all
on mouseUp pBtnNum
if pBtnNum is 1 then
put the dgHilitedLines of me into theLine
if word 1 of the target <> "scrollbar" then
put the dgDataOfLine[theLine] of group "datagrid 2" into theDataA
## theDataA is now an array variable.
## In the case of the Data Grid pictured above the keys of the array are id, label, col3, date_added and webname
put theDataA["label 1"] into field tchosen
put theDataA["label 2"] into field ttopic
put theDataA["label 3"] into field tdescript
visual effect "push left fast"
go to card "forum_details"
end if
end if
end mouseUp