How Do I Open a Table Cell For Editing?
By default a table cell can be edited if the user double-clicks on the cell. This tutorial explains what goes on in the default column behavior so you can customize behavior if you would like.
Note: The default column behavior is stored in button "Default Column" of stack "revDataGridLibrary"
In order to edit the columns of a data grid table you need to know about the following:
1) The EditFieldText command
2) The EditValue message
3) The EditKey and EditKeyOfIndex commands
4) The CloseFieldEditor command which can be sent as a result of calling EditFieldText.
Read up on the entries for EditFieldText, EditValue, EditCell/EditCellOfIndex in the API documentation.
The EditFieldText command will create an editor for a field that you specify. The default column behavior calls this command with all three parameters so that data is automatically saved after the user finishes editing.
EditValue is the message that is sent to a row when a request to edit a fields contents has been made. The default column behavior calls EditFieldText when this message is received.
There are two commands that will open a cell for editing. They are EditCell and EditCellOfIndex. Each takes the name of the column you want to edit and the line or index you want to edit. Here are two example scripts showing how you could use these commands in the script of a data grid.
put "FirstName" into theColumn put the dgHilitedLine of me into theLineNo EditCell theColumn, theLineNo
put "FirstName" into theColumn put the dgHilitedIndex of me into theIndex EditCellOfIndex theColumn, theIndex
Either of the above calls will trigger the EditValue message.
on EditValue ## Example of opening a field editor for the targeted column. ## Since I'm passing in parameters 2 and 3 any changes will automatically be saved to the dgData. EditFieldText the long id of me, the dgIndex of me, the dgColumn of me end EditValue
If the user changes any content in the field editor this message will be sent to the field targeted in the first parameter sent to EditFieldText. Read the API docs for EditFieldText which discusses this message.
Example of storing value in dgData in CloseFieldEditor. This would be required if you only passed in one parameter to EditFieldText.
on CloseFieldEditor pFieldEditor put the dgIndex of me into theIndex put the dgDataOfIndex[theIndex] of the dgControl of me into theDataA put the text of pFieldEditor into theDataA[the dgColumn of me] set the dgDataOfIndex[theIndex] of the dgControl of me to theDataA end CloseFieldEditor