File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
src/main/java/com/flowingcode/vaadin/addons/twincolgrid Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,33 @@ public TwinColGrid<T> addSortableColumn(
328328 return this ;
329329 }
330330
331+ /**
332+ * Adds a new sortable text column to this {@link Grid} with a value provider. The column will use
333+ * a {@link TextRenderer}. The value is converted to a String using the provided {@code
334+ * itemLabelGenerator}.
335+ *
336+ * @param itemLabelGenerator the value provider
337+ * @param comparator the in-memory comparator
338+ * @param header the column header
339+ * @param header the column key
340+ * @return this instance
341+ */
342+ public TwinColGrid <T > addSortableColumn (
343+ final ItemLabelGenerator <T > itemLabelGenerator ,
344+ Comparator <T > comparator ,
345+ final String header ,
346+ final String key ) {
347+ forEachSide (
348+ side ->
349+ side .grid
350+ .addColumn (new TextRenderer <>(itemLabelGenerator ))
351+ .setHeader (header )
352+ .setComparator (comparator )
353+ .setSortable (true )
354+ .setKey (key ));
355+ return this ;
356+ }
357+
331358 public TwinColGrid <T > withoutAddAllButton () {
332359 addAllButton .setVisible (false );
333360 checkContainerVisibility ();
You can’t perform that action at this time.
0 commit comments