vaadin / vaadin/framework

Listening to Grid.EditorMoveEvent

Open
#8,028 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

I request a method to trap (listen to) Grid.EditorMoveEvent be made available to achieve it from the Server side. If it can currently be done can you please advise how, as EditorListener does not work.

I have seen previous replies to posts related to this issue that EditorListener was "dropped" because it does not work in Java 8. I understand that alternatives were suggested to achieve this from the client side however I request for the option to trap this event from the Server side.

The background is as follows. I use the Grid in a layout which provides a menubar where an Update menu, which has an Unlock sub-menu, becomes available only when the user selects a row. If the user selects Unlock, I start the editor with with the following sequence:

sqlc.setAutoCommit(false); // sqlc is the SQLContainer set as the data source for grid
grid.setEditorEnabled(true);
final NonNullFieldGroup nonNullFieldGroup = new NonNullFieldGroup(); // a FieldGroup which suppresses the word null being shown in empty cells
grid.setEditorFieldGroup(nonNullFieldGroup);
grid.setEditorBuffered(false);
grid.editItem(selectedRow); // selectedRow is the itemId of the clicked row

When the user is finished with changes, the menubar offers Commit Update or Cancel Update submenus and the changes are committed or rolled back according to user selection in the respective methods.

When the Editor is set in unbuffered mode as above for a Vaadin Grid, I have observed that not only that editing is much more "elegant" as it is "in line" with no separate editor pane being opened, you can even edit multiple rows without setting the selection mode to Multi, thus avoiding a tickbox column and making the UI simple and elegant for the user, like a spreadsheet. The only problem is that as the user moves from row to row the changes made to earlier rows vanish from the view, (the original values are displayed again) although the changes are "there" and if the user then presses the Commit Update menu they are made.

All I want is to somehow keep the changes visible as the user moves from row to row. I think this can be done by trapping the EditorMoveEvent. In there I will use grid.clearSortOrder which makes the changed values visible. I have observed that after grid.editItem(selectedRow); is executed, grid.addItemClickListener and grid.addSelectionListener events do not fire when the user clicks on a new row to edit it.

I have observed that grid.addFocusListener event does fire so I have tried to accomplish my objective with grid.addFocusListener, and the changes do become visible as I use grid.clearSortOrder in the event method. However I have observed that if the user presses the tab key to move between cells, and at times even if he uses the mouse to move between cells, the user can lose cell focus while editing and the row can become uneditable until the user presses a double click on it! This must be happening as this event itself would be firing due to user movements within the same row. I would like to avoid this behaviour and I believe this can be accomplished if the EditorMoveEvent could be trapped and used, as that event should not fire till the user moves to a new row.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Grid editor event API and the existing EditorListener and FocusListener behavior described in the issue. Determine whether a server-side event can represent movement between edited rows without firing for cell focus changes; done means the requested event is available with behavior that preserves visible edits while moving between rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.