Spreadsheet-like behavior of dataGrid

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rbrucep
Posts: 21
Joined: Thu Jul 05, 2012 4:25 pm

Spreadsheet-like behavior of dataGrid

Post by rbrucep » Sat Jan 19, 2013 9:57 pm

Apologies if this re-posts; first effort appears not to be showing up.

I'm trying to activate the cell BELOW the current one after user enters data
(i.e. user enters '33' and clicks <RETURN>; I'd like the cell immediately below the one with the 33 to become active for editing)

I've tried 'focus on' after retrieving the names of the fields in the dataGrid, but this seems to be disallowed

Is there a dg command or simple trick I should be thinking of?

Thanks!
Bruce

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Spreadsheet-like behavior of dataGrid

Post by dunbarx » Mon Jan 21, 2013 6:47 pm

Hi.

There might be several ways to do this, but check out the "closeFieldEditor" message in the datagrid docs.

If you put this into the group script:

Code: Select all

on closeFieldEditor
   put the target
end closeFieldEditor
You will see that the field just edited appears in the message box when you change any data and hit return. You can use this to select the field below. You might see:

field "Col 2 0002"

And then you can select field "Col 2 0003"

Craig Newman

rbrucep
Posts: 21
Joined: Thu Jul 05, 2012 4:25 pm

Re: Spreadsheet-like behavior of dataGrid

Post by rbrucep » Fri Jan 25, 2013 4:04 am

Thanks!
I'll give it a whirl.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Spreadsheet-like behavior of dataGrid

Post by dunbarx » Fri Jan 25, 2013 6:34 am

A better way to do this, since scrolling a datagrid may not return the correct line number when using "the target", is to:

Code: Select all

on closeFieldEditor
      put the dghilitedLines of me && word 2 of the dgColumn of the target
end closeFieldEditor
You can now know which row of which column was just edited, and navigate accordingly.

Craig Newman

Post Reply