Page 1 of 1

Datagrid - Mouse up or selection change

Posted: Mon Apr 28, 2014 11:38 am
by Simon Knight
Hi ,

I have a datagrid showing a list of records. The list is for viewing only and when the user selects a row I want to populate a number of fields and buttons with data from the selected row. I have created my own default column behavior based on the standard one. Into this I have added the following code :

Code: Select all

On MouseUp
   put the dgline of me  into tline -- counts down the list not sure how this relates to the data
   put the dgDataOfLine[tline] of me into tRecA
   DisplaySelectedRow tRecA
   pass MouseUp
end MouseUp
The code reads the line number of the row where the mouse up occurs then it reads the data from the row into an array variable. Next it calls the routine DisplaySelectedRow on the card and passes it the array of data. It all seems to work. However, given that I treat datagrids with the same caution I would give to a nest of vipers is my code o.k. or have I introduced an as yet undetected "feature" ? Is there a better way of achieving the same result ?

Simon K

Re: Datagrid - Mouse up or selection change

Posted: Mon Apr 28, 2014 12:17 pm
by Klaus
Hi Simon,

I always use the "selectionchanged" message for this kind of stuff!

Advantage: this will also cover selections made with the ARROW keys!

Code: Select all

on selectionChanged pHilitedIndex, pPrevHilitedIndex
  put the dgDataOfLine[pHilitedIndex] of me into tRecA
  ## do your stuff here
  ## ...
end selectionChanged
Best

Klaus

Re: Datagrid - Mouse up or selection change

Posted: Mon Apr 28, 2014 1:07 pm
by Simon Knight
Klaus,

Thanks, where does the handler go ?

Simon

Re: Datagrid - Mouse up or selection change

Posted: Mon Apr 28, 2014 1:10 pm
by Klaus
Hi Simon,

that goes into the script of the datagrid GROUP (NOT the ROW behavior!)


Best

Klaus

Re: Datagrid - Mouse up or selection change

Posted: Mon Apr 28, 2014 1:12 pm
by Simon Knight
Klaus,

I found the lesson and now know its inside the group script.

Thanks again,

Simon