zryip.theslug at gmail.com
Wed Dec 21 14:25:04 EST 2011
On Wed, Dec 21, 2011 at 5:12 PM, Charles Szasz <cszasz at mac.com> wrote:
> I am using the Form version of DataGrid and not a table. The form is a scrolling field. I have one field "strategy" that displays statements from an array. This works fine. But as I stated before I have not been able to add an Edit Field (field "freq").
> When I include the following code for a Edit Field (field "freq") in the Behavior script, the statements from my Strategy field disappears!
> on FillInData pDataArray
> set the text of field "Strategy" of me to pDataArray["Strategy"]
> set the text of field "freq" of me to empty
> end FillInData
> on LayoutControl
> local theFieldRect,theMasterRect
> put the rect of me into theMasterRect
> put the rect of field "Strategy" of me into theMasterRect
> set the left of field "Strategy" of me to item 1 of theMasterRect
> put the rect of field "freq" of me into theMasterRect
> set the right of field "freq" of me to item 4 of theMasterRect
> put the rect of grc "Background" of me into r
> set the rect of grc "Background" of me to r
> end LayoutControl
For editing a field in a datagrid form, you need a little more code
than the fillindata and layoutcontrol handlers.
First of all the LayoutControl handler have one parameter you can use
for getting the rect of me:
on LayoutControl pControlRect
In the LayoutControl handler, you are placing controls relatively to
their own rects instead of using the rect of the datagrid cell. I have
not tested the result of your code, but the result should be a bit
different than the result you are expecting.
This could maybe explain why the strategy field is not visible:
because it is maybe not include in the rect of the cell row.
Comment the layoutcontrol code and try again.
About editing a field in a datagrid form:
Most common usage is to edit a field by double clicking on it.
So you need a mouseDoubleUp handler in your behavior script:
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
EditFieldText the long id of the target, the dgIndex of me,"freq"
1. The field is editable only if the datagrid is editable (the
dgProps["allow editing"] of the dgControl of me)
2. With the EditFieldText handler we are assuming you have a key named
"freq" in your datagrid data.
3. the dgIndex of me is the index of the edited row.
For more information about the EditFieldText handler, have a look to
this datagrid lesson:
-Zryip TheSlug- wish you the best! 8)
More information about the Use-livecode