diff --git a/src/main/java/net/bootsfaces/component/ComponentsEnum.java b/src/main/java/net/bootsfaces/component/ComponentsEnum.java index ccf7b6a50..1c652d1ea 100644 --- a/src/main/java/net/bootsfaces/component/ComponentsEnum.java +++ b/src/main/java/net/bootsfaces/component/ComponentsEnum.java @@ -18,95 +18,234 @@ package net.bootsfaces.component; public enum ComponentsEnum { - accordion(" + * Usually this method is called internally by the JSF engine. + */ + public void setRowGroup(String _rowGroup) { + AddResourcesListener.addResourceIfNecessary("https://cdn.datatables.net/rowgroup/1.0.2/js/dataTables.rowGroup.min.js"); + super.setRowGroup(_rowGroup); + } } diff --git a/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java b/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java index a1fbc4ea5..8d0044464 100644 --- a/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java +++ b/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java @@ -24,7 +24,7 @@ public abstract class DataTableCore extends UIData implements net.bootsfaces.render.IHasTooltip { protected enum PropertyKeys { - ajax, border, colLg, colMd, colSm, colXs, columnVisibility, contentDisabled, copy, csv, customLangUrl, customOptions, delay, deselectOnBackdropClick, disabled, display, excel, fixedHeader, hidden, immediate, info, lang, largeScreen, markSearchResults, mediumScreen, multiColumnSearch, multiColumnSearchPosition, offset, offsetLg, offsetMd, offsetSm, offsetXs, onclick, oncomplete, ondblclick, ondeselect, onerror, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onorder, onpage, onsearch, onselect, onsuccess, pageLength, pageLengthMenu, paginated, pdf, print, process, responsive, rowHighlight, rowStyleClass, saveState, scrollCollapse, scrollHorizontally, scrollSize, scrollX, searching, select, selectedColumn, selectedItems, selectedRow, selectionInfo, selectionMode, smallScreen, span, striped, style, styleClass, tinyScreen, tooltip, tooltipContainer, tooltipDelay, tooltipDelayHide, tooltipDelayShow, tooltipPosition, update, visible, widgetVar; + ajax, border, colLg, colMd, colSm, colXs, columnVisibility, contentDisabled, copy, csv, customLangUrl, customOptions, delay, deselectOnBackdropClick, disabled, display, excel, fixedHeader, hidden, immediate, info, lang, largeScreen, markSearchResults, mediumScreen, multiColumnSearch, multiColumnSearchPosition, offset, offsetLg, offsetMd, offsetSm, offsetXs, onclick, oncomplete, ondblclick, ondeselect, onerror, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onorder, onpage, onsearch, onselect, onsuccess, pageLength, pageLengthMenu, paginated, pdf, print, process, responsive, rowGroup, rowHighlight, rowStyleClass, saveState, scrollCollapse, scrollHorizontally, scrollSize, scrollX, searching, select, selectedColumn, selectedItems, selectedRow, selectionInfo, selectionMode, smallScreen, span, striped, style, styleClass, tinyScreen, tooltip, tooltipContainer, tooltipDelay, tooltipDelayHide, tooltipDelayShow, tooltipPosition, update, visible, widgetVar; String toString; PropertyKeys(String toString) { @@ -903,6 +903,22 @@ public void setResponsive(boolean _responsive) { getStateHelper().put(PropertyKeys.responsive, _responsive); } + /** + * Group the rows by a common column value. Can be a number or a Json-object, as documented at https://datatables.net/reference/option/#rowgroup.

+ * @return Returns the value of the attribute, or null, if it hasn't been set by the JSF file. + */ + public String getRowGroup() { + return (String) getStateHelper().eval(PropertyKeys.rowGroup); + } + + /** + * Group the rows by a common column value. Can be a number or a Json-object, as documented at https://datatables.net/reference/option/#rowgroup.

+ * Usually this method is called internally by the JSF engine. + */ + public void setRowGroup(String _rowGroup) { + getStateHelper().put(PropertyKeys.rowGroup, _rowGroup); + } + /** * Enable the row highlight css. Default: true.

* @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file. diff --git a/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java b/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java index 9a3dc49ea..398ec6e5e 100644 --- a/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java +++ b/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java @@ -611,6 +611,18 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce if (selectCommand.length() > 0) { options = addOptions("'initComplete': function( settings, json ) { " + selectCommand + "}", options); } + + if (dataTable.getRowGroup()!=null) { + String rowGroup = dataTable.getRowGroup(); + try { + Integer.parseInt(rowGroup); + options = addOptions("orderFixed: [" + rowGroup + ", 'asc']", options); + rowGroup = "rowGroup:{dataSrc:" + rowGroup + "}"; + } catch (NumberFormatException itsJson) { + // consider it a Json object + } + options = addOptions(rowGroup, options); + } rw.writeText(widgetVar + " = $('." + clientId + "Table" + "');" + // # Get instance of wrapper, and replace it with the unwrapped table. diff --git a/src/main/meta/META-INF/bootsfaces-b.taglib.xml b/src/main/meta/META-INF/bootsfaces-b.taglib.xml index 6539802a5..603afbfe9 100644 --- a/src/main/meta/META-INF/bootsfaces-b.taglib.xml +++ b/src/main/meta/META-INF/bootsfaces-b.taglib.xml @@ -6359,6 +6359,18 @@ false java.lang.Boolean + + + row-group + false + java.lang.String + + + + rowGroup + false + java.lang.String + row-highlight diff --git a/xtext/BootsFaces.jsfdsl b/xtext/BootsFaces.jsfdsl index 7efd34f52..136c90de1 100644 --- a/xtext/BootsFaces.jsfdsl +++ b/xtext/BootsFaces.jsfdsl @@ -562,6 +562,7 @@ widget dataTable paginated Boolean default "true" "Activates the pagination of the dataTable. Default value is 'true'." responsive Boolean "Activates the responsive plugin of the dataTable" rendered Boolean inherited "Boolean value to specify the rendering of the component, when set to false the component will not be rendered." + row-group "Group the rows by a common column value. Can be a number or a Json-object, as documented at https://datatables.net/reference/option/#rowgroup." row-highlight Boolean default "true" "Enable the row highlight css. Default: true." row-style-class "Optional CSS class for each row. If it's an EL expression, it's evaluated for each row. You can also provide a comma-separated list. In this case, the CSS classes are assigned cyclically to the row." save-state Boolean default "true" "Stores the state of the datatable on the client, so that after a page reload the same filters are active, the same page is shown etc."