senthil_sss
senthil_sss

Reputation: 193

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]"

can one help me in fixing this...

Upvotes: 1

Views: 1165

Answers (1)

Max
Max

Reputation: 1157

I believe this is a Primefaces bug.

I think the correct sort details should be passed to LazyDataModel.load() when paging in order to use in in your DB query.

Adding

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

to the shouldDecode method in org.primefaces.component.datatable.feature.SortFeature should resolve this issue.

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

Upvotes: 1

Related Questions