1
votes

Hello guys I have a problem with my datatable I want to filter it, but if i put something into the text field nothing is shown and also if i clear the input also nothing. It is possible if i have more than one statment in a column?

So I use primefaces 3.5 and jsf 2.1

Here is the code and if you need more code post an comment. thx

<p:dataTable id="inboxTable" var="task" value="#{taskboxBean.taskboxInboxList}" paginator="true"
            widgetVar="inboxTable" rows="10" selection="#{taskboxBean.selectedTaskbox}"
            selectionMode="single" rowKey="#{task.ID}" emptyMessage="" paginatorPosition="bottom"
            filteredValue="#{taskboxBean.inboxList}">

            <p:ajax event="rowSelect" update=":contentForm, :postForm:tabViewPosts:inboxTable"
                listener="#{taskboxBean.onTaskboxRowSelect}" />

            <f:facet name="header">  

                <p:outputPanel>
                    <h:outputText value="Suchen:" />
                    <p:inputText id="globalFilter" onkeyup="inboxTable.filter()"
                        style="margin-left:5px;width:150px" />
                </p:outputPanel>
            </f:facet>

            <p:column headerText="Post">
                <h:outputText
                    value="#{task.FROM_USER.FIRST_NAME} #{task.FROM_USER.LAST_NAME} (#{task.FROM_USER.EMAIL})" />
                <div align="right">
                    <h:panelGroup rendered="#{!task.IS_SEEN}" class="fa fa-envelope fa-2x" />
                    <h:panelGroup rendered="#{task.IS_SEEN}" class="fa fa-envelope-o fa-2x" />
                </div>
                <h:outputText value="#{task.TASKTYPE.NAME}" />
                <br />
                <h:outputText value="#{task.CREATE_TIMESTAMP}" />
            </p:column>

        </p:dataTable>
2

2 Answers

2
votes

It is not explicitely written in documentation, but as mentioned on PrimeFaces forum, you need to declare filterBy attribute on columns you want to make searchable via global filter.

It is also suggested here to add filterStyle="display:none" to columns if you don't want a filter to be visible on individual columns.

The example from documentation has filterBy:

<p:dataTable var="car" value="#{carBean.cars}"
        filteredValue="#{carBean.filteredCars}" widgetVar="carsTable">
    <f:facet name="header">
        <p:outputPanel>
            <h:outputText value="Search all fields:" />
            <h:inputText id="globalFilter" onkeyup="carsTable.filter()" />
        </p:outputPanel>
    </f:facet>
        <p:column filterBy="#{car.model}" headerText="Model" filterMatchMode="contains">
            <h:outputText value="#{car.model}" />
        </p:column>
</p:dataTable>

however, as typical for PrimeFaces documentation, it's not written that it won't work without filterBy.

0
votes

You must add getter and setter of your taskboxInboxList in the taskboxBean class. But it filters just the first statement placed in the column.