1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    2
    Vote Rating
    0
    tprice is on a distinguished road

      0  

    Default Focus the first CellEditor in a EditorGrid

    Focus the first CellEditor in a EditorGrid


    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:

    Code:
    // 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?

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    2
    Vote Rating
    0
    tprice is on a distinguished road

      0  

    Default


    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.

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Nov 2010
    Posts
    209
    Vote Rating
    -2
    Ersmarker has a little shameless behaviour in the past

      0  

    Default


    You can listen to the ViewReady event and then start the editor
    Code:
            grid.addListener(Events.ViewReady, new Listener<BaseEvent>() {
                @Override
                public void handleEvent(BaseEvent be) {
                    grid.startEditing(0, 0);
                }
            });

Thread Participants: 1

Tags for this Thread