LiveCode LessonsLiveCode Data Grid Using The Built-In Field EditorHow Can I Customize The Field Editor Behavior?

How Can I Customize The Field Editor Behavior?

By default the Data Grid field editor allows users to enter data and save it back to the Data Grid. If you need data entry to behave differently you can assign your own behavior script to the field editor before it opens. This lesson will show you how.

Create Your Behavior Script

Create Your Behavior Script

1) Create a button to hold the behavior script you want to use with the Data Grid field editor. I've placed this button on the same card as the data grid.

2) Set the script of your button to the script of button "Field Editor" of stack "revDataGridLibrary". This is the behavior script that Data Grid uses by default and is a good place to start when customizing the behavior.

Customize Your Script

Customize Your Script

Make any customizations you need to make.

Assign Your Custom Behavior to Field Editor

Assign Your Custom Behavior to Field Editor

Whenever the Data Grid displays the field editor (e.g. the user double-clicks on a cell in a table) a preOpenFieldEditor message is sent the Data Grid. The first parameter is a reference to the field editor control. This is where you can assign your behavior script to the field.

1 Comments

Simon Knight

This caused me problems as initially I had my behavior button stored first on the column template and then on a group that the datagrid was part of. In these locations the preopenfieldeditor script failed to find the behavior button which results in a "silent" failure where the datagrid stops allowing cell editing. This failure was corrected by entering the full long ID of the behavior button which restored cell editing but my behavior code was still not being called. It was only called when I placed the button on the parent card/stack.

Add your comment

E-Mail me when someone replies to this comment