From 2cd670cf62aa9ea07e2231bc58abfe4008be5c24 Mon Sep 17 00:00:00 2001 From: jens Date: Fri, 22 Nov 2019 14:20:10 +0100 Subject: [PATCH] Add DataTables "lengthChange" option 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. --- .../component/dataTable/DataTableCore.java | 18 +++++++++++++++++- .../component/dataTable/DataTableRenderer.java | 1 + src/main/meta/META-INF/bootsfaces-b.taglib.xml | 12 ++++++++++++ xtext/BootsFaces.jsfdsl | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java b/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java index bc27d3457..61a8bdfe4 100644 --- a/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java +++ b/src/main/java/net/bootsfaces/component/dataTable/DataTableCore.java @@ -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, @@ -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.

+ * @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.

+ * 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).

* @return Returns the value of the attribute, or , false, 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 a930ad1ec..9c7185248 100644 --- a/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java +++ b/src/main/java/net/bootsfaces/component/dataTable/DataTableRenderer.java @@ -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); diff --git a/src/main/meta/META-INF/bootsfaces-b.taglib.xml b/src/main/meta/META-INF/bootsfaces-b.taglib.xml index bc36ca530..8dd66789a 100644 --- a/src/main/meta/META-INF/bootsfaces-b.taglib.xml +++ b/src/main/meta/META-INF/bootsfaces-b.taglib.xml @@ -6563,6 +6563,18 @@ false java.lang.String + + + length-change + false + java.lang.Boolean + + + + lengthChange + false + java.lang.Boolean + mark-search-results diff --git a/xtext/BootsFaces.jsfdsl b/xtext/BootsFaces.jsfdsl index 0b965ed96..f53efdb45 100644 --- a/xtext/BootsFaces.jsfdsl +++ b/xtext/BootsFaces.jsfdsl @@ -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, <b:inputText /> 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'."