PDA

View Full Version : Focus the first CellEditor in a EditorGrid



tprice
23 Jan 2012, 2:56 PM
I have an EditorGrid that I would like to initially displayed in an editing mode with the cursor focused on the first cell that has a CellEditor.

Here is some example code of how I'm setting up my editor and grid:



// build the combo boxListStore<MyComboModel> comboStore = SenchaQuestions.SAMPLE_COMBO_STORE;
final ComboBox<MyComboModel> combo = new ComboBox<MyComboModel>();
combo.setForceSelection(true);
combo.setTypeAhead(true);
combo.setValueField("id");
combo.setDisplayField("name");
combo.setStore(comboStore);


// create the CellEditor
CellEditor comboEditor = new CellEditor(combo) {
// .. @Overrides preProcessValue and postProcessValue to go from Strings to models
}


// build the grid
List<ColumnConfig> columnConfigs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig("a_model_property", "Column To Edit", 250);
column.setEditor(editor);
columnConfigs.add(column);
ListStore<MyGridModel> store = SenchaQuestions.SAMPLE_GRID_STORE;
EditorGrid<MyGridModel>grid = new EditorGrid<MyGridModel>(store, new ColumnModel(columnConfigs));



How can I get the first cell of the "Column To Edit" to be focused?

tprice
23 Jan 2012, 3:01 PM
As a second question: is there a way to provide default empty text for the combo box when it is used in a CellEditor? If I do combo.setEmptyText("This is the empty text...") the text is not showing up in the EditorGrid.

Ersmarker
1 Feb 2012, 4:02 AM
You can listen to the ViewReady event and then start the editor


grid.addListener(Events.ViewReady, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
grid.startEditing(0, 0);
}
});