0
votes

I am using primeface6.0, i have a datatable with data of 50 records and have paginator along with filter option, i am filtering data which does not exist in table and onclear boolean column is setting to false, below is the code.

<p:dataTable id="inventorytbl" value="#{inventorybean.inventoryList}"
                var="inventory" rows="15" paginator="true"
                paginatorPosition="bottom" pageLinks="5"
                paginatorAlwaysVisible="false" widgetVar="inventoryWidget"
                rowKey="#{inventory.code}"
                paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">

                <f:facet name="header">
                    <p:outputPanel>
                        <p:outputPanel>
                            <p:inputText id="globalFilter"
                                onkeyup="PF('inventoryWidget').filter()"
                                onkeypress="if (event.keyCode == 13) {return false; }"
                                style="width:150px;float: right;margin-left: 5px;"
                                placeholder=" Enter keyword" />
                        </p:outputPanel>
                    </p:outputPanel>
                </f:facet>

                <p:column headerText="Material Name" style="width:23%"
                    sortBy="#{inventory.materialName}"
                    filterBy="#{inventory.materialName}" filterMatchMode="contains"
                    filterStyle="display:none;visibility:hidden;">
                    <div title="#{inventory.materialName}">
                        #{inventory.materialName}</div>
                </p:column>
                // onfilter clearing button inside column getting disable(default to false)
                <p:column style="width: 10%;text-align: -webkit-center;"
                    headerText="Action" filterBy="#{inventory.activeFlag}"
                    filterMatchMode="contains"
                    filterStyle="display:none;visibility:hidden;">
                    <p:commandButton id="musterupdatelnk"
                        action="edit"


                        disabled="#{not inventory.activeFlag}" 
                        icon="fa fa-pencil-square-o"/>
                </p:column>

1

1 Answers

0
votes

I'm not sure if the built-in filter clear feature works properly, but I've ran into similar issue and have decided to create my own custom 'clear' button and placed it inside a column header.

            <p:column style="width: 16px;" exportable="false">
                <f:facet name="header">
                    <p:commandLink id="clearFilterLink" onclick="PF('WidgetVar').clearFilters();"  styleClass="clear-filter-icon" />
                    <p:tooltip for="clearFilterLink" value="Clear Filters" trackMouse="true" position="right"/>
                </f:facet>
                <p:rowToggler />
            </p:column>

This is just for your reference, but I think you can do something similar. Maybe create a button somewhere on the page that clears the filter on click?