summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2018-03-27 14:53:15 +0300
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-03-27 14:53:15 +0300
commit98be8f19d046f8f0fd7fe5a753bff2c67efed9fd (patch)
treeb7f9a91abdc40c2c791414c80b12e7cdee22f728 /server
parent8b2da456bdbda7cd493bd9dc11bbb1dead368d5c (diff)
downloadvaadin-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.java17
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