How Can I Store An Option Menu Value When The User Makes a Selection?
This lesson will demonstrate how to update the data associated with a row in a data grid when the user makes a selection from an option menu.
Here is the data grid we will be working with. Col 2 has been customized with an option menu. What we are going to do is update the data associated with a row to reflect the selection the user makes in the option menu.
We need to customize the column behavior. From the Columns pane (1) in the Property Inspector select Col 2 and then click the Column Behavior button (3).
In the FillInData handler we are setting the menuhistory based on the value of pData that is passed in.
We can add a a menuPick handler to the column behavior script in order to accomplish our goal. When the user makes a selection from the option menu the menuPick message is sent by the engine. We can then use the SetDataOfIndex command to update the value for the column. The parameters for SetDataOfIndex are the index, the column name and the new value. Since the above script is in a column behavior we can use the dgIndex of me (1) for the index and the dgColumn of me (2) for the column name.
Here is what the data grid's internal array looks like before making a menu selection.
After making a selection for row 2 (1) we can see that the internal value was updated (2).