I did a little research on the Primefaces data table, and here are my findings.
Actually, recompilation is not needed, replace the original javascript.
You need to register a new handler for the filter event, not the one provided by Primefaces.
In this case, the data table will be used as follows:
<h:outputScript name="js/customprimefacestable.js" target="body"/> <p:dataTable var="data" value="#{filterBean.data}" filteredValue="#{filterBean.filteredData}" widgetVar="tableWidget"> <p:column filterBy="#{data.name}" headerText="Name" filterMatchMode="contains"> <h:outputText value="#{data.name}" /> </p:column> <p:column filterBy="#{data.value}" headerText="Value" filterMatchMode="contains"> <h:outputText value="#{data.value}" /> </p:column> ... </p:dataTable>
And javascript will look like this:
$(document).ready(function() { tableWidget.thead.find('> tr > th.ui-filter-column > .ui-column-filter').each(function() { var filter = $(this); if(filter.is('input:text')) { if(tableWidget.cfg.filterEvent!="enter"){
Notes :
target="body" : javascript should not be executed in <head> because Primefaces initializes its widget variables in $(document).ready() , therefore it is not guaranteed that your function will be executed after Primefaces initialization;- since filtering starts with at least 4 characters entered in the column search field (done), you must restore the unfiltered view when the user deletes the text up to 4 characters on his own (not performed);
- the solution above is aimed at Primefaces 3.5
<p:dataTable> . The implementation of Primefaces varies from version to version, so be sure to check the version of your version or upgrade to version 3.5; - implementation of filtering events with input fields displayed as pop-up windows is not distributed;
- the table will listen for the default event (
keyup ).
skuntsel
source share