I am curious, but why are you trying to render a textfield when the Grid has a native editor that works like a textfield? Is there some feature you need to take advantage of?
If not, I would try a simpler approach, and one that is more elegant. What works best for me (in most cases) is setting the following:
grid.setImmediate(true);
grid.setEditorEnabled(true);
grid.setEditorBuffered(false);
Then, when needing to watch for editor movement, I implemented the following listeners:
[code]
grid.addEditorListener(new Grid.EditorListener() {
@Override
public void editorOpened(Grid.EditorOpenEvent editorOpenEvent) {
ModuleData row = (ModuleData) editorOpenEvent.getItem();
complexGrid.select(row);
App.EVENT_BUS.post(new GridEnableEvent(getSession().getSession().getId(), false));
}
@Override
public void editorMoved(Grid.EditorMoveEvent editorMoveEvent) {
ModuleData row = (ModuleData) editorMoveEvent.getItem();
complexGrid.select(row);
}
@Override
public void editorClosed(Grid.EditorCloseEvent editorCloseEvent) {
App.EVENT_BUS.post(new GridEnableEvent(getSession().getSession().getId(), true));
}
});
[/code]I have specific events that need firing when the Grid goes in and out of editing mode, but maybe you don’t need that.
Also, for specific columns that I care an especially large amount for, I do something like the following:
TextField valueField = new TextField();
grid.getColumn("valueColumn").setEditorField(valueField);
Now you can set whatever TextField properties you want to the valueField (such as addValueChangeListener, addShortcutListener, addBlurListener or whatever you so desire … coincidentally, not all TextField event listeners work properly, but most do)
That was my solution, up until a few weeks ago when the Vaadin team put together a very impressive piece of code,
GridFastNavigation Add-on
. This is a very versatile editor for the Grid that has helped us a great deal, but that’s an entirely different conversation.