Skip to content

Commit 1435207

Browse files
koendecockjavier-godoy
authored andcommitted
Add the possibility to align the export buttons to the left #18
1 parent 128ddd2 commit 1435207

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.flowingcode.vaadin.addons.gridexporter;
2+
3+
public enum ButtonsAlignment {
4+
LEFT,RIGHT
5+
}

src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public class GridExporter<T> implements Serializable {
6666

6767
public int totalcells = 0;
6868

69+
private ButtonsAlignment buttonsAlignment = ButtonsAlignment.RIGHT;
70+
6971
private GridExporter(Grid<T> grid) {
7072
this.grid = grid;
7173
}
@@ -105,13 +107,32 @@ public static <T> GridExporter<T> createFor(Grid<T> grid, String excelCustomTemp
105107
hl.add(csvLink);
106108
}
107109
hl.setSizeFull();
108-
hl.setJustifyContentMode(JustifyContentMode.END);
110+
111+
hl.setJustifyContentMode(exporter.getJustifyContentMode());
112+
109113
GridHelper.addToolbarFooter(grid, hl);
110114
}
111115
});
112116
return exporter;
113117
}
114-
118+
119+
private JustifyContentMode getJustifyContentMode() {
120+
JustifyContentMode justifyContentMode;
121+
if(this.buttonsAlignment == ButtonsAlignment.LEFT)
122+
{
123+
justifyContentMode = JustifyContentMode.START;
124+
}
125+
else
126+
{
127+
justifyContentMode = JustifyContentMode.END;
128+
}
129+
return justifyContentMode;
130+
}
131+
132+
public void setButtonsAlignment(ButtonsAlignment buttonsAlignment) {
133+
this.buttonsAlignment = buttonsAlignment;
134+
}
135+
115136
Object extractValueFromColumn(T item, Column<T> column) {
116137
Object value = null;
117138
// first check if therer is a value provider for the current column

0 commit comments

Comments
 (0)