Pagination + Sorting in DataTables

UI Components for JSF
Post Reply
danielandross
Posts: 29
Joined: 14 Feb 2011, 12:39

14 Feb 2011, 17:12

Hello,

is it possible to do sorting of columns within datatables using pagination?
Are there any samples? In the showcase there is only sorting and pagination but not both together. When I set the sortby Attribute in the Table it won't do anything on my table. I think it is because I use pagination.

I implemented a lazyModel overriding its load() method. The table content is supplied via hibernate.

Is Pagination + interactive Sorting of columns possible at all?

regards

MikeK
Posts: 104
Joined: 13 Oct 2010, 15:07

17 Feb 2011, 15:47

It can be done. There are some side effects like the scoll bar not extending to the headers and it will not render properly if you try to load and empty dataset. My guess is you do not have a height on the table.

Your p:dataTable should look like this..

Code: Select all

<p:dataTable id="table" var="prop" value="#{propList.propList}"  scrollable="true" height="100" paginator="true" rows="100" >
You then have to add widths to the p:column tags like this...

Code: Select all

<p:column sortBy="#{prop.propPropertyId}" style="width: 100px;" >
Prime Faces 6.2
Mojarra 2.2.14
Apache Tomcat 9.0
Internet Explorer 10,11

danielandross
Posts: 29
Joined: 14 Feb 2011, 12:39

21 Feb 2011, 11:23

I got my Sorting working now thank you. My Problem now is that the width of the rows will depend on the length of the given column. This means the entities will have different width as the column labels.

How can I disable that?

Code: Select all

style="width: 100px;"
I think this line will set a maximum width, but I want a fix width.

A column now looks like this:

Code: Select all

<pf:column sortBy="#{table.name}" filterBy="#{table.name}">
				<f:facet name="header">
					${resourceBundle['list.name']}
				</f:facet>					
					<h:outputText value="#{list.name}"/>
				</pf:column>
Thank you.

Edit: Found the Problem: It was the scrolling. Without

Code: Select all

scrollable="true"
it works

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests