diff options
author | Tatu Lund <tatu@vaadin.com> | 2018-03-27 14:53:15 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-03-27 14:53:15 +0300 |
commit | 98be8f19d046f8f0fd7fe5a753bff2c67efed9fd (patch) | |
tree | b7f9a91abdc40c2c791414c80b12e7cdee22f728 /server | |
parent | 8b2da456bdbda7cd493bd9dc11bbb1dead368d5c (diff) | |
download | vaadin-framework-98be8f19d046f8f0fd7fe5a753bff2c67efed9fd.tar.gz vaadin-framework-98be8f19d046f8f0fd7fe5a753bff2c67efed9fd.zip |
Add row index to ItemClickEvent in Grid (#10754)
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 22ac453216..0eeb132d50 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -347,6 +347,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, private final T item; private final Column<T, ?> column; private final MouseEventDetails mouseEventDetails; + private final int rowIndex; /** * Creates a new {@code ItemClick} event containing the given item and @@ -354,11 +355,12 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, * */ public ItemClick(Grid<T> source, Column<T, ?> column, T item, - MouseEventDetails mouseEventDetails) { + MouseEventDetails mouseEventDetails, int rowIndex) { super(source); this.column = column; this.item = item; this.mouseEventDetails = mouseEventDetails; + this.rowIndex = rowIndex; } /** @@ -397,6 +399,15 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, public MouseEventDetails getMouseEventDetails() { return mouseEventDetails; } + + /** + * Returns the clicked rowIndex. + * + * @return the clicked rowIndex + */ + public int getRowIndex() { + return rowIndex; + } } /** @@ -625,10 +636,10 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, @Override public void itemClick(String rowKey, String columnInternalId, - MouseEventDetails details) { + MouseEventDetails details, int rowIndex) { Column<T, ?> column = getColumnByInternalId(columnInternalId); T item = getDataCommunicator().getKeyMapper().get(rowKey); - fireEvent(new ItemClick<>(Grid.this, column, item, details)); + fireEvent(new ItemClick<>(Grid.this, column, item, details, rowIndex)); } @Override |