1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    16
    Vote Rating
    1
    eprice is on a distinguished road

      0  

    Default NPE in GridSelectionModel onEditorKey()

    NPE in GridSelectionModel onEditorKey()


    I have an EditorGrid where not all columns have an attached editor. When navigating the grid using the Tab key, I get a NPE. Somehow the editor is being returned as null.

    In the onEditorKey() method of GridSelectionModel there is a check to see if the editor is null, but then the editor is used in the call to grid.walkCells().

    Code:
      public void onEditorKey(DomEvent e) {
        int k = e.getKeyCode();
        Cell newCell = null;
        CellEditor editor = grid.editSupport.getActiveEditor();
    
    
        switch (k) {
          case KeyCodes.KEY_ENTER:
          case KeyCodes.KEY_TAB:
            e.stopEvent();
            if (editor != null) {
              editor.completeEdit();
            }
            if ((k == KeyCodes.KEY_ENTER && moveEditorOnEnter) || k == KeyCodes.KEY_TAB) {
              /*
               *  if editor is null, as checked for above, then the lines below throw NPE
               */
              if (e.isShiftKey())  {
                newCell = grid.walkCells(editor.row, editor.col - 1, -1, callback, true);
              } else {
                newCell = grid.walkCells(editor.row, editor.col + 1, 1, callback, true);
              }
            }
            break;
    I'm not sure why the editor is null, as that should be the source of the event. So I'm looking into that. But in the case when the editor really is null, how can navigation continue to the next editable cell?

  2. #2
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Can you please provide a fully working testcase implementing EntryPoint?

Thread Participants: 1