Datagrid edit cell question

Marcello Bertoli mbertoli at libero.it
Wed Mar 24 15:33:43 EDT 2010


Hi all,

I have some questions about editing data directly inside datagrids.

The scenario is a datagrid where the user can edit only certain columns. I've accomplished this turning off the "allow text editing" of the datagrid and allowing the text editing of the column I want in the mouseDoubleUp handler. Here it is a sample code:

on mouseDoubleUp pMouseBtnNum
   dgMouseDown pMouseBtnNum
   if the dgHeaderControl of the target is empty
      if pMouseBtnNum is 1 then
         put the dgColumn of the target into tColumn
         put the dgHilitedIndex of the target into tIndex
         switch tColumn
            case "column I don't want to edit"
               exit mouseDoubleUp
               break
            default
               EditCellOfIndex tColumn, tIndex
         end switch
      end if
   end if
   
Is it the best way to manage my purpose or are there better methods?

Actually if I cicle through the columns of a datagrid row with the tab key I can edit the columns I don't want to edit. I've tried to solve the problem with this code:

on preOpenFieldEditor pFieldEditor
   switch the dgColumn of the target
      case "Column I dont'want to edit"
         send "DeleteFieldEditorAndOpenNext" to the dgControl of me in 0 seconds
         break
      [...]
   end switch
end preOpenFieldEditor

It actually works but:

1. I don't know if it is the best way to manage the problem
2. I see that the focus is sent to the "column I don't want to edit" and then the cursor jumping to the column I actually want to edit.

I would like not to see this effect. I would like the cursor jumping directly to the cell of the column where the user can insert data without this unpleasant graphic effect. Is there a way to accomplish this?

Thanks in advance
Cheers
Marcello


More information about the use-livecode mailing list