Skip to content

Commit

Permalink
#945 added the rowGroup feature to b:dataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed May 29, 2018
1 parent fe42e80 commit 1d23fee
Show file tree
Hide file tree
Showing 6 changed files with 279 additions and 90 deletions.
317 changes: 228 additions & 89 deletions src/main/java/net/bootsfaces/component/ComponentsEnum.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,14 @@ public void setMarkSearchResults(boolean _markSearchResults) {
}
super.setMarkSearchResults(_markSearchResults);
}

/**
* 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. <P>
* 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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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. <P>
* @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. <P>
* 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. <P>
* @return Returns the value of the attribute, or true, if it hasn't been set by the JSF file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/main/meta/META-INF/bootsfaces-b.taglib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6359,6 +6359,18 @@
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[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.]]></description>
<name>row-group</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[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.]]></description>
<name>rowGroup</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Enable the row highlight css. Default: true.]]></description>
<name>row-highlight</name>
Expand Down
1 change: 1 addition & 0 deletions xtext/BootsFaces.jsfdsl
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit 1d23fee

Please sign in to comment.