Friday, June 15, 2012

Dojo and the Grid !!!

DataGrid is making me pull my hair out.  I just wanted to be able to use a custom widget in the grid to edit things.  Worked pretty well, until we needed to make it AlwaysEditing (when the edit button was clicked).

If you have a button to edit, DO NOT USE AlwaysEditing and set the grid to editable.  It didn't work for me at least.

The way to do it is to return the widget from the formatter function, you create two functions and toggle between them depending on the state of your edit button.  Gottcha's include setting selectable for the grid in order to select text with your mouse, and override onCellClick so that the grid doesn't cause your widget to lose focus on the first click.