简体   繁体   English

在 <p:dataTable> 分页不适用于dynamicColumns + lazy + sorting

[英]In <p:dataTable> pagination not working with dynamicColumns+lazy+sorting

i'm having a lazyloading Datatable with dynamic columns generated 我正在使用动态列生成的惰性加载数据表

this is my dataTable 这是我的数据表

<p:dataTable var="iterator" id="dataTable" 
            value="#{MyManagedBean.lazyModel}" 
        paginator="true" rows="20"
            lazy="true">
    <p:columns value="#{MyManagedBean.columns}" var="column"
             columnIndexVar="colIndex"  
             sortBy="#{iterator[column.property]}"
               filterBy="#{iterator[column.property]}">
        <f:facet name="header">  
                   #{column.header}  
               </f:facet>  
            #{iterator[column.property]}  
   </p:columns> 
</p:dataTable>

this works perfect without pagination. 完美无分页。 if i paginate, load() method does not give the SortField value, instead it gives me "property]" 如果我分页,load()方法没有给出SortField值,而是给了我“属性”

can one help me in fixing this... 可以帮我解决这个问题吗?

I believe this is a Primefaces bug. 我相信这是Primefaces错误。

I think the correct sort details should be passed to LazyDataModel.load() when paging in order to use in in your DB query. 我认为应该在分页时将正确的排序详细信息传递给LazyDataModel.load()以便在您的数据库查询中使用。

Adding 添加

|| (table.isLazy() && table.isPaginationRequest(context))

to the shouldDecode method in org.primefaces.component.datatable.feature.SortFeature should resolve this issue. org.primefaces.component.datatable.feature.SortFeature中的shouldDecode方法应该可以解决此问题。

public boolean shouldDecode(FacesContext context, DataTable table) {
    return isSortRequest(context, table) || (table.isLazy() && table.isPaginationRequest(context));
}

I've crated a new issue: https://code.google.com/p/primefaces/issues/detail?id=7068 我提出了一个新问题: https : //code.google.com/p/primefaces/issues/detail? id = 7068

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

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