Page 1 of 1

Get Data from another Column - Data Grid

Posted: Fri Apr 19, 2013 3:28 pm
by FinishTheCode
I am really struggling with Data Grids.

If a line of data is selected in a data grid, how do I get a particular piece of data from one of the columns.

For example if i had this

Column 1 - Worker Type
Column 2 - Normal Cost Per Hour
Column 3 - After Hour Cost Per Hour
Column 4 - Weekend Cost Per Hour

If that row was selected, how would I get the data from column 4 and put it into a text field.

Re: Get Data from another Column - Data Grid

Posted: Fri Apr 19, 2013 3:56 pm
by dunbarx
Hi.

Everyone struggles with datagrids until you get used to them. Then you struggle some more. But they are tremendous.

There are many ways to do this. Select a line in the DG. In a button script, try:

Code: Select all

on mouseUp
   put the dgHilitedLine of grp yourDG into tLine
   get the dgDataOfline[tLine] of grp yourDG
   combine it with return and tab
   answer it
end mouseUp
You can now extract whatever you want from that line.

Or, how about this for brevity:

Code: Select all

on mouseup
answer line (the dgHilitedLine of grp yourDG) of the dgText of grp yourDg
end mouseup
Craig Newman

Re: Get Data from another Column - Data Grid

Posted: Sat Apr 20, 2013 1:41 pm
by snm
Put script:

Code: Select all

on dgMouseUp
   local tLine
   
   put the dgHilitedLine of grp "myDataGrid" into tLine
   get the dgDataOfline[tLine] of grp "myDataGrid"
   put it["Col 4"] into fld "myField"
end dgMouseUp
as your DataGrid group script (must change the name of DataGrid used in this script to the name of your DataGrid group).

It should do exactly what you asked.

Marek