Page 1 of 1

Datagrid - failure of dgHilitedLine / dgHilitedIndex

Posted: Fri Jan 02, 2015 9:29 am
by Simon Knight
Hi,
I am trying to use a datagrid form for the first time to display some data held in a TSV file. I am at the stage where I would like to be able to edit the data held in certain "fields" and have found a tutorial named "How can the user edit field content in a Data Grid Form?".

The tutorial calls for a new handler to be added to "## Placed in script of row template behavior" which I take to mean the script that is opened when the button "Row Behavior..." is pressed in the object inspector.

Two versions of a mousedown handler are listed, the first extracts the dgHilitedLine the second the dgHilitedIndex. for purposes of experimentation and testing I have merged these two examples in to this handler which is in the Row Behavior:

Code: Select all

On mouseDown pBtnNum
   if pBtnNum is 1 then
      if the short name of the target is "Title" then
         put "Title" into theKey
         put the dgHilitedIndex of me into theIndex
         put the dgHilitedLine of me into theLineNo
         answer "Mouse up fires, the index is : " & theIndex & " The Line number is : " & theLineNo
         -- EditKey thekey, theLineNo
         -- EditKeyOfIndex theKey, theIndex
      end if
   end if
end mouseDown
The handler is being called but neither of the variables "theIndex" or "theLineNo" is being populated. Obviously I have made an error, do you have any ideas where?

best wishes

Simon K

Re: Datagrid - failure of dgHilitedLine / dgHilitedIndex

Posted: Fri Jan 02, 2015 7:40 pm
by sritcp
Hi Simon:

If you are using "on mouseDown", then try retrieving "the dgLine" rather than "the dgHilitedLine".
The highlighting of the line may not happen until the mouse is released.

Alternatively, use "on mouseUp" to retrieve "the dgHilitedindex", etc.

Regards,
Sri.

Re: Datagrid - failure of dgHilitedLine / dgHilitedIndex

Posted: Fri Jan 02, 2015 10:55 pm
by Simon Knight
Sri,

Thanks for spotting my silly mistake!

best wishes

Simon K