can we do a internal sorting in primeface datetable ? If i have column a ,b ,c. can i sort the column c and then internally by column b in p:dataTable.
<h:form>
<p:dataTable var="car" value="#{tableBean.carsSmall}">
<p:column headerText="Model">
<h:outputText value="#{car.model}" />
</p:column>
<p:column headerText="a">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="b">
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column headerText="c">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
</h:form>
Yes, you can. http://www.primefaces.org/showcase/ui/datatableSortingMultiple.jsf
P.S Don't forget pressing CTRL or Cmd :)
Related
I am developing web using PrimeFaces 6.0 components. On
<p:dataTable> component when we set scrollable="true" option, columns headers alignment goes wrong.
Following is my code snippet:
<p:fieldset legend="Machine Test Match" id="panel233" toggleable="true" toggleSpeed="500" >
<!--<p:panel id="panel233" header=" Machine Test Match" style="height:325px;border: none">-->
<p:dataTable id="testmatchtable" var="testMatchvalues" value="#{manufactureBean.listTestMatchata}" filteredValue="#{manufactureBean.filteredManufacture}" editable="true"
styleClass="mystyle" tableStyle="table-layout:auto;width:100% important!;" rowKey="#{testMatchvalues.testId}" scrollRows="10" scrollable="true" scrollHeight="230" rows="40" liveScroll="true" selection="#{manufactureBean.testMatchModel}" selectionMode="single" resizableColumns="true" >
<p:column headerText="Test ID" filterBy="#{testMatchvalues.testId}" filterMatchMode="contains" style="width:35px">
<h:outputText value="#{testMatchvalues.testId}" />
</p:column>
<p:column headerText="Test Desc" filterBy="#{testMatchvalues.testDesc}" filterMatchMode="contains" style="width:35px" >
<h:outputText value="#{testMatchvalues.testDesc}" />
</p:column>
<p:column headerText="Specimen Desc" filterBy="#{testMatchvalues.specimenDesc}" filterMatchMode="contains" style="width:35px" >
<h:outputText value="#{testMatchvalues.specimenDesc}" />
</p:column>
<p:column headerText="Path Test Desc" filterBy="#{testMatchvalues.pathTestDesc}" filterMatchMode="contains" style="width:35px">
<h:outputText value="#{testMatchvalues.pathTestDesc}" />
</p:column>
<p:column headerText="Path Param Name" style="width:35px" filterBy="#{testMatchvalues.parameterName}" filterMatchMode="contains">
<h:outputText value="#{testMatchvalues.parameterName}" />
</p:column>
<p:column headerText="Additional Factor" style="width:35px" >
<h:outputText value="#{testMatchvalues.additionFactor}" />
</p:column>
<p:column headerText="Multiply Factor" style="width:35px">
<h:outputText value="#{testMatchvalues.multiplyFactor}" />
</p:column>
<p:column headerText="Machine Host Code" style="width:35px">
<h:outputText value="#{testMatchvalues.machineHostCode}" />
</p:column>
<p:column headerText="Active" style="width:35px">
<h:outputText value="#{testMatchvalues.active}" />
</p:column>
</p:dataTable>
<!--</p:panel>-->
</p:fieldset>
Code taken from https://www.primefaces.org/showcase/ui/data/datatable/basic.xhtml
Attached image shows the problem clearly as column headers and data is not aligned properly.
Image link
For p:column, width="4%" works for me rather than using '4px'
I have an List of List. lets say student and address. one to many relationship. In my data table there are 3 columns for the Name, Surname, Age related to the Student and In a single column I need to show address with concatenating the following fields like, address1, address2, city, country.Now I need to export this table by using <p:dataExporter>. When I try to export as Excel the corresponding column of Address is exported as Object (org.primefaces.uirepeat. blah blah..)
My code is
<p:dataTable value="#{manager.studentList}" var="item" id="studentData">
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{item.name}" />
</p:column>
<p:column>
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{item.surname}" />
</p:column>
<p:column>
<f:facet name="header">Age</f:facet>
<h:outputText value="#{item.age}" />
</p:column>
<p:column>
<f:facet name="header">Address</f:facet>
<ui:repeat value="#{studentBean.addressList}" var="address">
<h:outputText value="#{address.address1}" /> <br />
<h:outputText value="#{address.address2}" /> <br />
<h:outputText value="#{address.city}" /> <br />
<h:outputText value="#{address.country}" />
</ui:repeat>
</p:column>
</p:dataTable>
<h:commandLink>
<p:graphicImage name="/images/excel.png" />
<p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/>
</h:commandLink>
Suggest me some way to export. even I tried with c:forEach and columns.
<p:dataTable value="#{manager.studentList}" rowIndexVar="index" var="item" id="studentData">
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{item.name}" />
</p:column>
<p:column>
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{item.surname}" />
</p:column>
<p:column>
<f:facet name="header">Age</f:facet>
<h:outputText value="#{item.age}" />
</p:column>
<p:column>
<f:facet name="header">Address</f:facet>
<c:forEach var="address" items="#{studentBean.addressList.get(index).address}">
<h:outputText value="#{address.address1}" />,
<h:outputText value="#{address.address2}"/>,
<h:outputText value="#{address.city}" />,
<h:outputText value="#{address.country}" />
</c:forEach>
</p:column>
</p:dataTable>
<h:commandLink>
<p:graphicImage name="/images/excel.png" />
<p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/>
</h:commandLink>
i trying with c:forEach is ok
I have a treeTable where I have to set on the first column a Radionbutton.
the RadionButton is not linked to the treeTable.
I tried with the selectionMode but in vain.
If you have any idea, please share it with me.
Thanks in advance :)
My treeTable should look like this :
here is the code I used :
<p:treeTable value="#{treeBouchon.racine}" var="ligneBudgetaire"
selection="#{treeBouchon.ligneBudgetaireselectionnee}"
selectionMode="single" rowKey="#{ligneBudgetaire.id}">
<p:column selectionMode="single">
</p:column>
<p:column headerText="Ligne budgétaire">
<h:outputText value="#{ligneBudgetaire.filed1}" />
</p:column>
<p:column headerText="ETP reçus">
<h:outputText value="#{ligneBudgetaire.filed2}" />
</p:column>
<p:column headerText="ETP émis">
<h:outputText value="#{ligneBudgetaire.filed3}" />
</p:column
</p:treeTable>
I am trying to use the p:rowToggler and p:rowExpansion in my datatable. It was working fine on primefaces 3.2, recently i upgraded to primefaces 3.5. Since then it is not working. Following is the datatable with roToggler and rowExpansion
<p:datatable value="#{myBean.valueList}">
<p:column>
<p:rowToggler/>
</p:column>
<p:rowExpansion>
...
</p:rowExpansion>
</p:datatable>
Any help would be appreciated
Thanks
Praveen
Please try as below,
<p:dataTable var="education"
value="#{backingBean.schoolList}"
reflow="true"
paginator="true"
sortMode="multiple"
emptyMessage="No records found."
rows="#{backingBean.rowsPerPage}">
<p:column headerText="Details" styleClass="Wid10">
<p:rowToggler expandLabel="Show" collapseLabel="Hide" icon="ui-icon-close"/>
</p:column>
<p:column headerText="Center">
<h:outputText value="#{education.centerName}"/>
</p:column>
<p:column headerText="Address">
<h:outputText value="#{education.addr}" />
</p:column>
<p:rowExpansion>
<p:outputLabel value="Course: " styleClass="FontBold" />
<BR />
<h:outputText value="#{education.course}" />
<Br />
<p:outputLabel value="Details: " styleClass="FontBold" />
<BR />
<h:outputText value="#{education.details}" />
</p:rowExpansion>
</p:dataTable>
I have a form with a panel and two dataTables. The code below has had most of the columns removed to make it easier to follow.
<h:form id="invoiceLookUp">
<p:panel>
<f:facet name="header">
<p:column style="font-weight: bold;">
Invoice Selection Criteria
</p:column>
</f:facet>
<h:outputText value="Seq ID"/>
<p:inputText
id="invoice_header_seq_id" styleClass="field" size="10"
value="#{invoiceBean.invoice_header_seq_id}"
/>
<p:commandButton
update="invoicesTable" value="Look Up"
action="#{invoiceBean.addInvoices()}"
/>
</p:panel>
<p:dataTable
id="invoicesTable" var="invoice" rows="15" lazy="true" selectionMode="single"
value="#{invoiceBean.invoiceList}"
rowKey="#{invoice.invoiceHeader.invoiceHeaderSeqId}"
selection="#{invoiceBean.selectedInvoice}"
>
<p:ajax event="rowSelect" update=":invoiceLookUp:invoiceLinesTable"/>
<f:facet name="header"><h:outputText value="Invoice Headers" /></f:facet>
<p:column sortBy="#{invoice.invoiceHeader.invoiceHeaderSeqId}" id="invoiceSeqId">
<f:facet name="header">
<h:outputText value="Seq ID" title="Invoice Header Seq ID"/>
</f:facet>
<h:outputText value="#{invoice.invoiceHeader.invoiceHeaderSeqId}" />
</p:column>
</p:dataTable>
<p:dataTable
id="invoiceLinesTable" var="invoiceLine" rows="15" lazy="true" selectionMode="single"
value="#{invoiceBean.selectedInvoice.invoiceLines}"
rowKey="#{invoiceLine.invoiceLineSeqId}"
selection="#{invoiceBean.selectedInvoiceLine}"
>
<f:facet name="header"><h:outputText value="Invoice Lines" /></f:facet>
<p:column sortBy="#{invoiceLine.invoiceLineSeqId}" id="invoiceLineSeqId">
<f:facet name="header"><h:outputText value="Line Seq ID"/></f:facet>
<h:outputText value="#{invoiceLine.invoiceLineSeqId}"/>
</p:column>
</p:dataTable>
</h:form>
When you enter a Seq ID and then click Look Up, the table populates as expected. When I select a row in the invoicesTable, I get the following error:
javax.faces.FacesException: Cannot find component with identifier ":invoiceLookUp:invoiceLinesTable" referenced from "form:invoiceLookUp:invoicesTable".
Can anyone tell me what I am doing wrong?