I oppologize in advance for all the posts I have had recently, but these client side extensions are killing me.
Currently, my task is simple. When somone has a row selected in the grid and they press UP or DOWN, it needs to go up a row or down a row and SELECT the row. If the editor is opened, it needs to save the data, close the editor, then move up/down respectively. This seems reasonably simple, and I thought I understood what I need to do.
I downloaded the sample project from
here
, and began changing things around a bit. Everything has been working well, until I added the following code to the extend() function in the EditorHandlingOverrideExtensionConnector class:
grid.addDomHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
JsonObject selectedRow = grid.getSelectedRow();
if(event.getNativeKeyCode()== KeyCodes.KEY_DOWN ){
for (int i = 0; i < grid.getDataSource().size(); i++) {
JsonObject tRow = grid.getDataSource().getRow(i);
if (selectedRow.equals(tRow)) {
grid.select(grid.getDataSource().getRow(row + 1));
grid.select(grid.getSelectedRow());
break;
}
}
}else if(event.getNativeKeyCode()== KeyCodes.KEY_UP ){
for (int i = 0; i < grid.getDataSource().size(); i++) {
JsonObject tRow = grid.getDataSource().getRow(i);
if (selectedRow.equals(tRow)) {
grid.select(grid.getDataSource().getRow(row - 1));
grid.select(grid.getSelectedRow());
break;
}
}
}
}
}
, KeyDownEvent.getType());
I understand that this code isn’t bulletproof, it is simply supposed to work when the editor is closed and they press up/down. However, once I press either the up/down arrow, I get the following exception:
This client-side selection model SingleSelectionModel does not know selected row.java.lang.UnsupportedOperationException: This client-side selection model SingleSelectionModel does not know selected row.
at Unknown.$fillInStackTrace(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.Exception(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.RuntimeException_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.UnsupportedOperationException_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.$getSelectedRow(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.getSelectedRow(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.$getSelectedRow_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.handleMoveEvent_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.$handleEvent_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.onBrowserEvent_49(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.dispatchEvent_4(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.dispatchEvent_6(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.apply_0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.entry0(org.vaadin.customgrid.CustomGridWidgetset-0.js)
at Unknown.<anonymous>(org.vaadin.customgrid.CustomGridWidgetset-0.js)
I don’t understand why. The grid.select function is copied from the example. Is this just not possible in the DomHandler? If so, what do I do here?
Please help …