Skip to content

Commit

Permalink
Add DataTables "lengthChange" option
Browse files Browse the repository at this point in the history
This adds an attribute for the dataTables "lengthChange" property to the datatable. Offering the possibility to disable "false" the page length menu in the upper right. The default is "true", so it is still compatible with previous releases.
  • Loading branch information
sebsoftware authored and stephanrauh committed Apr 29, 2020
1 parent 140df9a commit 2cd670c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class DataTableCore extends UIData implements net.bootsfaces.ren
protected enum PropertyKeys {
ajax, autoUpdate, border, caption, colLg, colMd, colSm, colXs, columnVisibility, contentDisabled, copy, csv,
customLangUrl, customOptions, delay, deselectOnBackdropClick, disabled, display, excel, fixedHeader, hidden,
immediate, info, lang, largeScreen, markSearchResults, mediumScreen, multiColumnSearch,
immediate, info, lang, largeScreen, lengthChange, 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,
Expand Down Expand Up @@ -448,6 +448,22 @@ public void setLargeScreen(String _largeScreen) {
getStateHelper().put(PropertyKeys.largeScreen, _largeScreen);
}

/**
* Allows the user to disable the pageLength menu. Defaults to true. <P>
* @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file.
*/
public boolean isLengthChange() {
return (boolean) (Boolean) getStateHelper().eval(PropertyKeys.lengthChange, true);
}

/**
* Allows the user to disable the pageLength menu. Defaults to true. <P>
* Usually this method is called internally by the JSF engine.
*/
public void setLengthChange(boolean _lengthChange) {
getStateHelper().put(PropertyKeys.lengthChange, _lengthChange);
}

/**
* If true, search results are marked yellow as you type. Based on mark.js (see https://datatables.net/blog/2017-01-19). <P>
* @return Returns the value of the attribute, or , false, if it hasn't been set by the JSF file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ public void encodeEnd(FacesContext context, UIComponent component) throws IOExce
}
options = addOptions("pageLength: " + pageLength, options);
options = addOptions("lengthMenu: " + getPageLengthMenu(dataTable), options);
options = addOptions("lengthChange: " + dataTable.isLengthChange(), options);
options = addOptions("searching: " + dataTable.isSearching(), options);
options = addOptions("order: " + orderString, options);
options = addOptions("stateSave: " + dataTable.isSaveState(), options);
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 @@ -6563,6 +6563,18 @@
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description><![CDATA[Activates the page length menu of the dataTable. Default value is 'true'.]]></description>
<name>length-change</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[Activates the page length menu of the dataTable. Default value is 'true'.]]></description>
<name>lengthChange</name>
<required>false</required>
<type>java.lang.Boolean</type>
</attribute>
<attribute>
<description><![CDATA[If true, search results are marked yellow as you type. Based on mark.js (see https://datatables.net/blog/2017-01-19).]]></description>
<name>mark-search-results</name>
Expand Down
1 change: 1 addition & 0 deletions xtext/BootsFaces.jsfdsl
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ widget dataTable
immediate Boolean "Flag indicating that, if this component is activated by the user, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase. Default is false."
info Boolean default "true" "If set, this will enable the information about record count. Defaults to true."
lang String "Configured lang for the dataTable. If no default language is configured, the language configured in the browser is used."
length-change Boolean default "true" "Activates the page length menu of the dataTable"
mark-search-results Boolean "If true, search results are marked yellow as you type. Based on mark.js (see https://datatables.net/blog/2017-01-19)."
multi-column-search Boolean "If true, &lt;b:inputText /&gt; fields will be generated at the bottom of each column which allow you to perform per-column filtering."
multi-column-search-position default "bottom" "Should the multi-column-search attributes be at the bottom or the top of the table? Legal values: 'top','botton', and 'both'. Default to 'bottom'."
Expand Down

0 comments on commit 2cd670c

Please sign in to comment.