clickability in a DataGrid

Klaus on-rev klaus at major.on-rev.com
Wed Jan 23 08:33:35 EST 2013


Hej Sieg,

Am 23.01.2013 um 01:09 schrieb Sieg Lindstrom <sl at trackandfieldnews.com>:

> I've used LiveCode/RunRev for some time but an new to using DataGrids.
> 
> What I'd like to do (for Mac/Windows users) is include a DataGrid configured as, say, four columns of data followed by two columns that are the same in each row: one that reads "Delete" and one that reads "Edit." I'd like to set it up so that if the user clicks on "Delete" or "Edit" in a given row that then triggers handlers to either delete that row or edit the data contained in the other four columns of that row of the grid.
> 
> Using a standard text field with tab-delimited data in each row, I'd use the ClickText and the ClickLine in the field script to determine what the user clicked and trigger the appropriate actions. How would one achieve this in a DataGrid?
> 
> Thanks in advance!

well, DataGrids are extremely complex but also extremely powerful once you get to "master" them (more or less :-)

OK, presumed you have a datagrid of type TABLE with a column named "delete" and when the user clicks on that column
you want to delete the complete row of the datagrid, right?

Deleting ->Put this into the datagrids script:

on mouseup

  ## WHAT column has been clickedß
   put the dgColumn of the target into tClickedColumnName

  ## User clicked the column "delete":
   if tClickedColumnName = "delete" then

   ## Better ask EVERYTIME! ;-)
      answer "Really delete?" with "Cancel" or "OK"
      if it = "Cancel" then
         exit to top
      end if
      
     ## get the currently selected row
      put the dghilitedLines of me into tHL

    ## Now let the DG do the deletion
      dispatch "DeleteLines" to me with tHL
   end if
end mouseup

EDITING is definitively implemented in the default datagrid, just check "editable" in the inspector for the datagridand doubleclick 
any column to edit iits content. Or did I misunderstand your question about editing?

Get the complete datagrid manual as PDF here:
<http://lessons.runrev.com/m/datagrid>

Work through the example to get the grips.
I must confess that I need to re-read the docs everytime I did not work with DGs for more than one week, just too complex stuff :-D

> Sieg Lindstrom

Best

Klaus

--
Klaus Major
http://www.major-k.de
klaus at major.on-rev.com





More information about the use-livecode mailing list