Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a datable which includes the filter feature of primefaces. Some operations can be done on the table (e.g. edit). The datable will be updated after the user's operation is completed using ajax. It updates the table directly and works well, if I don't filter the datatable, unfortunately not if I use it and edit it.

That's how my datatable looks like:

    <p:dataTable id="dataTable" var="row"
                value="#{bean.value}"
                filteredValue="#{bean.filteredValue}"
                paginator="true" rows="25" paginatorPosition="bottom"
                rowKey="${row.id}"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                editable="true">

and the Button which triggers the update

<p:commandButton value="Save"
                        actionListener="#{bean.save}"
                        update=":form"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

After updating datatable you have to invoke it's client side filter() method.

<p:dataTable widgetVar="dataTableWidgetVar" id="dataTable" var="row"
             value="#{bean.value}"
             filteredValue="#{bean.filteredValue}"
             paginator="true" rows="25" paginatorPosition="bottom"
             rowKey="${row.id}"
             editable="true">

<p:commandButton value="Save"
                 actionListener="#{bean.save}"
                 update=":form"
                 oncomplete="PF('dataTableWidgetVar').filter()"/>

For PrimeFaces versions older than 5, you should use

<p:commandButton value="Save"
                 actionListener="#{bean.save}"
                 update=":form"
                 oncomplete="dataTableWidgetVar.filter()"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...