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'
Related
On selecting a row, I need to update the page which is in ui:insert of p:dialog. What my issue is when the page is loaded I can select the row and fetch the data. After selection of another row, I am not able to fetch. There is no action going on.
This is my dataTable
<p:ajax event="rowSelect" update="samples" />
<p:ajax event="rowUnselect" update="samples" />
<p:column headerText="SNo" style="width:20px;" >
#{rowIndex+1}
</p:column>
<p:column headerText="PatientId">
#{patServ.patientOrder.patientEpisode.patientRegistration.patientId}
</p:column>
<p:column headerText="Patient Name" >
#{patServ.patientOrder.patientEpisode.patientRegistration.firstName} #{patServ.patientOrder.patientEpisode.patientRegistration.lastName}
</p:column>
<p:column headerText="Visit ID">
#{patServ.patientOrder.patientEpisode.id}
</p:column>
<p:column headerText="Order ID">
#{patServ.patientOrder.id}
</p:column>
<p:column headerText="Barcode ID" >
<p:outputLabel value="#{resultEntryBean.getBarcodes(patServ.id)}" />
</p:column>
<p:column headerText="Department Name" >
#{loginBean.getSpecialityName( patServ.serviceLabData.serviceHeaderData.speciality )}
</p:column>
<p:column headerText="Service Name" >
#{patServ.serviceLabData.serviceHeaderData.serviceName}
</p:column>
<p:column headerText="Ordered Date">
<p:outputLabel value="#{patServ.createdOn}">
<f:convertDateTime pattern="dd/MM/yyyy hh:mm a" type="date" timeZone="IST" />
</p:outputLabel>
</p:column>
<p:column headerText="Status">
<p:outputLabel value="#{resultEntryBean.status == 3 ? 'Acknowledged': resultEntryBean.status == 5 ? 'Result Entered': resultEntryBean.status == 6 ? 'Result Authorized' : 'Result Deauthorized'}" />
</p:column>
<p:column>
<p:commandButton value="Print" icon="ui-icon-print" update="reportContent" disabled="#{empty resultEntryBean.selectedPatientService}" onclick ="PF('templateDlg').show()" ajax="true"/>
</p:column>
</p:dataTable>
and im updating xhtml in ui:include here in the dialog box
<p:dialog id="mainDialog" header="Selected Template" widgetVar="templateDlg">
<h:panelGroup id="reportContent">
<ui:include src="#{resultEntryBean.selectedTemplate()}.xhtml"></ui:include>
</h:panelGroup>
</h:form>
How should I update the xhtml file in the ui:include of p:dialog
I am using primefaces 3.4.2 jar. I have a datatable with four columns. In two columns I have a datalist and I want to export text showed by datalist. But when I export it, it shows the following "org.primefaces.component.datalist.DataList#1195cc3" in the pdf and xls file.
<p:dataTable emptyMessage="#{messages['empty.result.set']}" id="searchResult" var="row" value="#{managePessoaJuridica.manageableList}" rows="10" paginator="true" paginatorPosition="top" paginatorAlwaysVisible="false" style="display:#{managePessoaJuridica.manageableList == null? 'none': ''}">
<p:column styleClass="column_icons" exportable="false">
<p:panelGrid columns="#{pessoaJuridicaController.showSelectAction?3:2}">
<p:commandButton id="selectAction" icon="ui-icon-circle-check" title="#{messages['action.select']}" action="#{pessoaJuridicaController.select(row.id)}" immediate="true" process="#this" rendered="#{pessoaJuridicaController.showSelectAction}"/>
<p:commandButton id="editAction" icon="ui-icon-pencil" title="#{messages['action.edit']}" action="#{pessoaJuridicaController.load(row.id)}" immediate="true" process="#this" update="#form"/>
<p:commandButton id="deleteAction" icon="ui-icon-trash" title="#{messages['action.delete']}" action="#{pessoaJuridicaController.delete(row.id)}" immediate="true" process="#this" update="searchResult"
onclick="return confirm('#{messages['confirm.delete.this']} #{messages['pessoa.juridica.view.title']}');" />
</p:panelGrid>
</p:column>
<p:column id="column_nome" sortBy="#{row.nome}" >
<f:facet name="header">
<h:outputText id="columnHeader_nome" value="#{messages['pessoa.nome']}"/>
</f:facet>
<h:outputText id="nome" value="#{row.nome}">
</h:outputText>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_categoriasPessoa" value="#{messages['pessoa.categorias.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="categoriasPessoa" var="item" value="#{row.categoriasPessoa}" >
<p:column>
<h:outputText id="item_categoriasPessoa" value="#{item}" converter="com.domain.configuracao.crud.CategoriaPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_identificacoesPessoa" value="#{messages['pessoa.identificacoes.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="identificacoesPessoa" var="item" value="#{row.identificacoesPessoa}">
<p:column>
<h:outputText id="item_categoriaIdentificacoes" value="#{pessoaJuridicaController.getCategoriaIdentificacao(item)}" converter="com.domain.configuracao.crud.CategoriaIdentificacaoJsfConverter"/>:
<h:outputText id="item_identificacoesPessoa" value="#{item}" converter="com.domain.configuracao.crud.IdentificacaoPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column id="column_ativo" sortBy="#{row.ativo}" >
<f:facet name="header">
<h:outputText id="columnHeader_ativo" value="#{messages['classe.base.cadastro.ativo']}" />
</f:facet>
<h:outputText id="ativo" value="#{row.ativo}" converter="com.BooleanJsfConverter" >
</h:outputText>
</p:column>
<f:facet name="footer">
<p:menuButton value="#{messages['export.action']}" rendered="#{not empty managePessoaJuridica.manageableList}">
<p:menuitem value="#{messages['export.spreadsheet']}" ajax="false">
<p:dataExporter type="xls" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.pdf']}" ajax="false">
<pe:exporter type="pdf" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.csv']}" ajax="false">
<p:dataExporter type="csv" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
</p:menuButton>
<p:spacer width="10"/>
<h:outputText value="#{fn:length(managePessoaJuridica.manageableList)} #{messages['records.found']}" rendered="#{not empty managePessoaJuridica.manageableList}"/>
</f:facet>
</p:dataTable>
But when I export it, it shows the following
"org.primefaces.component.datalist.DataList#1195cc3" in the pdf and
xls file.
Obviously, Primefaces's data exporter use the toString() method of an object to print its "value(s)".
Suggestions :
Write a custom exporter (recommended)
Override toString() method of org.primefaces.component.datalist.DataList (not advised)
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 :)
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?