简体   繁体   English

过滤后的Primefaces数据表排序

[英]Primefaces datatable sorting after filtering

I have ap:dataTable which stores the results of a processed form, and I perform the following actions: 我有ap:dataTable,它存储已处理表单的结果,并且执行以下操作:

  1. Fill form values. 填写表格值。
  2. Submit. 提交。
  3. Data table is populated -- filter on any column. 数据表已填充-在任何列上进行过滤。
  4. Change form values. 更改表单值。
  5. Submit. 提交。
  6. Data table is populated with new results. 数据表将填充新结果。
  7. Sort on any column -- filtered results from #3 are displayed. 在任何列上排序-显示来自#3的过滤结果。

I have an arraylist for the filtered values, but I am not doing anything to it in the bean. 我有一个用于过滤值的arraylist,但是我在bean中没有对它做任何事情。 On submit, I am calling an actionListener which casts the dataTable to primefaces.components.datatable.DataTable and then calling a resetValue() on it (see code snippet below), before I process the form. 在提交时,我正在调用actionListener,它将数据表转换为primefaces.components.datatable.DataTable,然后在处理表单之前对其调用resetValue()(请参见下面的代码段)。

I've tried multiple ways of resetting, clearing and updating the dataTable, but I'm not able to get around the above issue. 我尝试了多种方法来重置,清除和更新dataTable,但无法解决上述问题。 Just for reference, this is my p:dataTable tag: 仅供参考,这是我的p:dataTable标记:

<p:dataTable
            id="resultsDataTable"
            rendered="#{entityReportBean.isResultsPopulated}"
            var="change"
            value="#{entityReportBean.entityChangeDto}"
            styleClass="resultsPanel"
            rows="100"
            paginator="true"
            paginatorPosition="top"
            paginatorTemplate="#{PreviousPageLink}  Previous  {CurrentPageReport}  Next  {NextPageLink}"
            filterEvent="enter"
            filteredValue="#{entityReportBean.filteredResults}" >

and this is the actionListener: 这是actionListener:

    public void onSubmit() {
            FacesContext context = FacesContext.getCurrentInstance();
            DataTable resultsTable = (DataTable) context.getViewRoot().findComponent("results:resultsDataTable");
            resultsTable.resetValue();
                ...

I am fairly new to JSF/Primefaces so there might be some basic operation I'm unaware of. 我对JSF / Primefaces相当陌生,因此可能有一些我不知道的基本操作。 Any suggestions? 有什么建议么?

So I realized that there was no point trying to do anything in my actionListener as that is not being invoked on sort. 因此,我意识到尝试在我的actionListener中做任何事情都是没有意义的,因为没有按类别进行调用。 So I added an ajax 'sort' event on the dataTable and added a resultsTable.updateValue(entityChangeDto); 因此,我在dataTable上添加了一个resultsTable.updateValue(entityChangeDto); '事件,并添加了一个resultsTable.updateValue(entityChangeDto); to the listener. 给听众。 Now all is well. 现在一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM