Challenge is with knowing the index of the item in the grid, since that is not known on the server side. This would require also scrollToItem(T item) to work also
What if the item is already selected? Can the editor already be opened for the selected item? I guess I'm missing something here, but how select(T item) is implemented right now if the key is unknown on the server side?
There is a big difference in showing a selection on a row and showing the editor. Basically the editor wants to scroll to the location of the edited row and display the editor on top of it, when the selection can be done for any object at any time even when it's not in the view port. We don't need to know where in the data set the object is to select it, but we do need to know the location for the object we want to scroll to and edit.
A simpler requirement even is to open the grid in editable mode. Manytimes, the grid is small and the user is expected to pick a row and edit it. The current requirement to double-click or use enter is ABSOLUTELY NOT intuitive.
Have you checked https://vaadin.com/directory#!addon/gridfastnavigation-add-on In addition to keyboard navigation enhancements it adds opening of the editor with single click. The Vaadin8 version is under development in vaadin8 branch https://github.com/TatuLund/GridFastNavigation/tree/vaadin8
We really need this possibility since our users can add an entry to the grid manually and are used to be able to start editing directly (in Vaadin 7 it was possible like that). The necessary double click before that is annoying to the user and definitely not intuitive.
Here's one workaround for opening the editor programmatically from the server-side:
thank you very much for providing a workaround! works, but obviously not the best approach and it would require quiet some adjustments on our side. will there be a functionality like that provided by the framework at some time?
to answer my own question: editRow(int rowIndex) now available in 8.2.0.alpha3
As far as I see it this workaround only solves the, now closed, issue #10040 which opens the editor for an item based on the index, as it uses grid.scrollTo(). I think this issue should be about editing or scrolling to an item by using the item itself.
The only solution that I see now to solve this problem is to traverse all the items in the DataProvider, while remembering the index, until the matching item is found. And this will probably be kind of slow in many environments...
Are there already any plans to provide some other means to support this?
I've tryed like stadler suggest. It works, but some rows appear blanked when I open editor. Opening first row will blank last 3 rows. As soon as a refresh event takes place (like sorting), rows re-appear. This never happens with double-click.
Vaadin 8.4. has now getRowIndex() in ItemClickEvent. This helps the case where you want to open the editor on clicked item.
grid.addItemClickListener(event -> {
grid.getEditor().editRow(event.getRowIndex());
});
Most helpful comment
A simpler requirement even is to open the grid in editable mode. Manytimes, the grid is small and the user is expected to pick a row and edit it. The current requirement to double-click or use enter is ABSOLUTELY NOT intuitive.