Page 1 of 1

update URL when user changes the value of a cell

Posted: Thu Sep 03, 2015 4:36 pm
by ittarter
In a basic table or datagrid, how would I get the program to response when a user changes the value of a cell, in such a way that the program knows which cell is being changed and can act accordingly (e.g. copy the changes to a URL)?

I'm envisioning the following scenarios. After changing the cell's value, the user:

-- tabs into another cell
-- presses the 'return' key
-- clicks anywhere in the app but outside the boundaries of the table/grid
-- clicks another cell
-- presses the 'up' 'down' 'left' 'right' key

Some of these I think I know (e.g. on keyDown up), but I don't know how livecode distinguishes between different cells in a way where I could get my program to know which item/line to validate/update.

Thanks :D

Re: update URL when user changes the value of a cell

Posted: Thu Sep 03, 2015 4:52 pm
by Klaus
Hi ittarter,

check the chapter "Using The Built-In Field Editor" in the datagrid docs!
A topic I could avoid so far! :D

Get the datagrid PDF here: http://lessons.runrev.com/m/datagrid


Best

Klaus

Re: update URL when user changes the value of a cell

Posted: Thu Sep 03, 2015 6:58 pm
by sritcp
Hi ittarter:

Put the following code into your datagrid script:

Code: Select all

on closeFieldEditor pFEditor 
 local tCol, tRowIndex
   put  the dgColumn of the target into tCol # name of column edited
   put the dgIndex of the target into tRowIndex #gives the dgIndex of the edited row
  # now do whatever you want with these data
end closeFieldEditor
Pressing tab, return, etc., etc., will close the editor and call this handler.
This will only work with datagrid table, not form.

Regards,
Sri

Re: update URL when user changes the value of a cell

Posted: Fri Sep 04, 2015 10:12 am
by ittarter
Very helpful, thanks guys :D