【问题标题】:p:datatable component is not sorting, only when I filter it beforep:datatable 组件不排序,只有当我过滤它之前
【发布时间】:2019-12-10 23:53:35
【问题描述】:

我试图在 Datatable 中显示我的 mysql 数据库中的数据,并且一切正常,现在我试图包含一个过滤器和排序功能,但是当我测试它并按下排序箭头时,什么都没有发生,只有当我先过滤数据表,然后一切正常。

我尝试使用 primeface Attributes filterBy 和 sortBy,由于现有功能,我认为它与更新问题有关

<p:dataTable id="test3" scrollable="true" scrollHeight="150"  var="Foo" value="#{Foo.bar}">
    
       <p:column headerText="#{msg['default-description-key']}" 
       sortBy="#{Foo.keyString}" 
       filterBy="#{Foo.keyString}">
                                            
           <p:outputLabel  value="#{Foo.keyString}" 
           style="float:center"/>     
                          
       </p:column>                                       
       <p:column headerText="#{msg['default-description-count']}" 
       sortBy="#{Foo.count}" filterBy="#{Foo.count}">
                                            
           <p:outputLabel value="#{Foo.count}" 
           style="float:center"/>
                                        
       </p:column>                                        
       <p:column headerText="#{msg['default-description-register.key']}">
                                            
           <p:commandLink value="#{msg['default-description- 
           register.key.link']}" action="#{Foo.bar(Foo.keyString)}"/>
                                        
       </p:column>
                                   
</p:dataTable>

我希望能够对数据表进行排序而无需之前对其进行过滤

【问题讨论】:

    标签: jsf primefaces


    【解决方案1】:
    • 在您的 bean 中创建一个单独的列表(不要忘记 getter 和 setter)并将其链接到 p:dataTable 组件中的属性 filteredValue
    • 将表格放在 h:form 中
    • 使用 h:outputText 代替 p:outputLabel

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-30
      • 2017-02-27
      • 1970-01-01
      • 1970-01-01
      • 2013-03-16
      • 2015-03-31
      • 1970-01-01
      相关资源
      最近更新 更多