Search code examples
gwtdatagridextjsgxt

GXT 3, editable grid, need to perform action on enter


I am new to GXT 3, and am confused by the API. Perhaps you could clarify.

In Editor Grid, how do I catch and examine keyboard keys pressed inside a cell in focus?


Solution

    1. Create your grid and pass it to GridEditing instance:

       final GridEditing<MyType> ge = new GridInlineEditing<MyType>(grid);
      

      // note: final Grid grid = new Grid(store, cm);

      // note: ColumnModel cm = new ColumnModel(configs);

      // note: List> configs = new ArrayList>();

    2. Construct your ColumnConfig

      ColumnConfig<MyType, String> kanji = new ColumnConfig<MyType, String>(kfgProps.kanji());
      

      // note: kfgProps here extends PropertyAccess

    3. Add your editor

      ge.addEditor(kanji, text);
      

      // note: text = new TextField();

    4. Add your DomHandler

      text.addDomHandler(new KeyDownHandler() {
      
          @Override public void onKeyDown(KeyDownEvent event) {
      
              if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
      
                  // do whatever
      
              }
          }
      
      }, KeyDownEvent.getType());