goodprg
goodprg

Reputation: 65

Custom filter for primefaces datatable

I am using PF3.2, JSF 2.0 with GF 3.1.

I have a datatable which has a custom filter on it. Everything works fine in Firefox but the datatable does not get updated in IE. When I click on anywhere in the page then the ajax gets fired and the datatable is updated.

Here is the code -

<p:dataTable id="std"
                                             value="#{myController.stdList}"
                                             selection="#{myController.std}"
                                             selectionMode="multiple"
                                             var="std"
                                             widgetVar="empTable"
                                             paginator="true"
                                             pageLinks="5"
                                             paginatorPosition="bottom"
                                             paginatorAlwaysVisible="true"
                                             currentPageReportTemplate="Page {currentPage} of {totalPages}"
                                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                                             rows="10"
                                             rowKey="#{std}"
                                             sortBy="#{std.lastName}"
                                             sortOrder="ascending"
                                             >
                                    <p:ajax event="rowSelect" 
                                            listener="#{myController.onRowSelectListener}" 
                                            process="@this"
                                            update="std"
                                            /> 

                                    <f:facet name="header">  
                                        <p:outputPanel>  
                                            <h:outputText value="#{bundle.GlobalFilterPrompt}" />  
                                    <p:inputText id="stdFilter" 
                                                 style="width:150px" 
                                                 valueChangeListener="#{myController.stdListener}">
                                        <p:ajax update="attendees" 
                                                process="@this" 
                                                event="change"
                                                />                     
                                    </p:inputText>

stdListener method reads the value from input box, gets new data and updates the datatable.

Why it does not work in IE?

Thanks

Upvotes: 1

Views: 2890

Answers (1)

Heather92065
Heather92065

Reputation: 7893

I've had success by invoking the dataTable's AJAX/jQuery filter() function using the PrimeFaces remoteCommand:

<p:inputText id="stdFilter" value="#{myController.myFilterValue}"
         style="width:150px">

<p:ajax event="change" onsuccess="myFilterUpdateCommand();"/>

<p:remoteCommand id="myRemoteCommandId" name="myFilterUpdateCommand"
                 actionListener="#{myController.stdListener()}"
                 update="attendees"
                 oncomplete="empTable.filter();"/>

I think you will need to add a value to your inputText component to get the filter value to the model/backing bean.

Upvotes: 1

Related Questions