How to customize the paginator from PrimeFaces datatable - jsf

I want to customize PrimeFace's data table pagination.
It is currently showing the page count at the bottom as: (1 of 5). I want to display the # of records in one page out of total number of records, such as: (1-10 of 50).
I have included my code below - but it isn't working. Could anyone please assist?
<p:dataTable id="tblStatusSearch" var="item" rowIndexVar="rowStatusSearch"
rows="10" paginator="true"
paginatorTemplate="{CurrentPageReport}
{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
value="#{StatusAction.listEBeans}"
<f:facet name="footer">
<h:outputText value="#{rowStatusSearch + 1} - 10 out of #{bondLocationStatusAction.itemCount}"/>
</f:facet>

You can use a PrimeFaces currentPageReportTemplate for the CurrentPageReport like this:
<p:dataTable id="tblStatusSearch" var="item" paginator="true" rows="10"
currentPageReportTemplate="Showing {startRecord}-{endRecord} out of {totalRecords}"
paginatorTemplate="{CurrentPageReport}
{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "
value="#{StatusAction.listEBeans}">
I confirm that it works in PrimeFaces 3.4.2. It is present in the users guide for PrimeFaces 3.0, so if you are using PrimeFaces 3.x it should work for you.

This will solve your purpose i think.
<p:dataTable id="datatable" var="car" value="#{myBean.cars}" paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {CurrentPageReport}"
currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords}">
<p:column...../>
<p:column...../>
</p:datatable>
In place of {CurrentPageReport} you will be able to see what you are looking for.

"please refer to the attached image" I think you have forgotten to attach image ;)
If you want to show the page size in your p:datatable you should declare two fields in your bean and hold the pageSize and first arguments values form load method inside them then you can show the page size with following paginatorTemplate:
paginatorTemplate=" {CurrentPageReport} #{yourBean.first + yourBean.pageSize} and rest of you template "
remember that EL works in paginatorTemplate property.

Related

Primefaces paginator selected button is not changing

So when Im trying to click 25 or 50, that amount of rows is displayed but selected button is still 12, what can be wrong?
<p:dataTable id="X_Y_Z" value="#{pSB.pDB}" var="prv" widgetVar="prvtab" emptyMessage="#{lbl.no_data}"
paginator="true" paginatorPosition="top" paginatorAlwaysVisible="true"
paginatorTemplate="{header} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="12,25,50" rows="#{pB.getNumber('P_BLNC')}"

is there any way to sort a datatable alphabetically in primefaces

I would like to know if there is any way to sort a datatable in primefaces alphabetically using a custom paginatortemplate or otherwise
<p:dataTable var="car" value="#{dtPaginatorView.cars}" rows="10"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
</p:dataTable>
Here you can find the Primefaces Datatable SortBy Attribut
<p:column headerText="Color" sortBy="#{car.color}">
<p:inputText value="#{car.color}" />
</p:column>

Neither sortBy nor filterBy of p:column are working inside composite component

Simply I have composite component of datatable using primefaces 4.0 the rendered output had no sorting facility nor filtering (i.e. column header has no arrows for sort and there is no input for filter field); my code as below
<composite:implementation> <p:dataTable value="#{cc.attrs.objectList}" var="item" resizableColumns="true" draggableColumns="true" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rows="10"
rowsPerPageTemplate="5,10,15" scrollable="true" scrollHeight="150" editable="true" editMode="cell" lazy="true" >
<c:if test="#{!empty cc.attrs.column1Value }">
<p:column sortBy="#{item[cc.attrs.column1Value]}" filterBy="#{item[cc.attrs.column1Value]}" headerText="#{cc.attrs.column1Label}" rendered="#{empty cc.attrs.column1InputList}">
#{item[cc.attrs.column1Value]}
</p:column>
</c:if>
I tried to change the value of sort by to be sortBy=#{cc.attrs.colum1Value} the sorting arrows appears but it doesn't work ... I'm using Jboss 6.1 Final GA, primefaces 4.0, Mojarra-2.0, jsf-impl-2.0.3-b05.jar. I appreciate your support to get sorting and filtering work inside composite component

Primefaces p:datatable how can we make a bottom scrollbar shown in a datatable?

My codes is like this...but no scrollbar shown in bottom.
how can we make a bottom scrollbar shown in a datatable?
<p:dataTable scrollHeight="250" id="data" var="item" value="#{saleOrderDetailViewModel.items}"
resizableColumns="true" liveResize="true" scrollable="true" rowIndexVar="rowInfo"
emptyMessage="#{pmtsCommonUtilViewModel.datatableEmptyMessage}"
paginatorPosition="bottom" paginator="true" rows="#{pmtsCommonUtilViewModel.rowsPerPage}"
rowsPerPageTemplate="#{pmtsCommonUtilViewModel.rowsPerPageTemplate}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column id="order_no" rendered="true" headerText="销售单编号" style="width:130px">
#{item.orderNo}
</p:column>
</p:dataTable>
Specify scrollWidth when you want bottom scrollbar shown.
Like this:
<p:dataTable scrollWidth="250" scrollHeight="250" id="data" var="item" value="#{saleOrderDetailViewModel.items}"
resizableColumns="true" liveResize="true" scrollable="true" rowIndexVar="rowInfo"
emptyMessage="#{pmtsCommonUtilViewModel.datatableEmptyMessage}"
paginatorPosition="bottom" paginator="true" rows="#{pmtsCommonUtilViewModel.rowsPerPage}"
rowsPerPageTemplate="#{pmtsCommonUtilViewModel.rowsPerPageTemplate}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column id="order_no" rendered="true" headerText="销售单编号" style="width:130px">
#{item.orderNo}
</p:column>
</p:dataTable>

JSF Pagination(Prime Faces)

I have 17000 data.and my rows per page is 20.So ideally it should display 850 pages.But to my surprise its only showing 500 pages .
Please help.
My code snippet is like this:-
<p:dataTable var="offer" value="#{viewReviseOffersCtrl.lazyModel}"
id="offerDetail" paginator="true" rows="#{msg['max.rows']}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
paginatorPosition="bottom"
rendered="#{not empty
viewReviseOffersCtrl.lstDisplayOffers}"
resizableColumns="true" scrollable="true" width="100%"
scrollHeight="265"
sortBy="#{offer.createdTs}"
lazy="true">

Resources