I try to make a data table group of PrimeFaces. All goes well. The number of columns is correct, colspan= "#{asignaturaController.nombrePruebasEscritas1.size()} but the name of each test does not show and the object pointed to is full. I tried everything.
Anyone have any idea?
This is my result.
but I need the names of "Pruebas" over the "pruebas"
<h:form id="form-tablapruebasescritas1"
renderer="#{asignaturaController.nombrePruebasEscritas1.size() != 0}">
<p:dataTable var="player"
value="#{asignaturaController.alumnos}"
id="tablapruebasescritas1"
style="margin-top:40px"
sortOrder="ascending">
<f:facet name="header">
1ª Evaluacion
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column rowspan="2" headerText="Alumno" />
<p:column colspan="#{asignaturaController.nombrePruebasEscritas1.size()}"
headerText="Pruebas" />
</p:row>
<p:row>
<ui:repeat value="#{asignaturaController.nombrePruebasEscritas1}"
var="yea">
<p:column headerText="#{yea}" />
</ui:repeat>
</p:row>
</p:columnGroup>
<p:column>
<h:outputText value="#{player.nombre}" />
</p:column>
<p:columns value="#{asignaturaController.nombrePruebasEscritas1}"
var="year">
<h:outputText value="#{player.getNotaParaTabla(year)}" />
</p:columns>
</p:dataTable>
</h:form>
Related
I can not correctly view the contents of a column with selectManyCheckbox in p:dataTable.
Here my .xhtml:
<h:form id="projAccess" enctype="multipart/form-data">
<p:dataTable tableStyle="width:auto" id="i_dtb2" var="p" value="#{comBean.l_uSrcRes}" paginator="true" rows="5" rowsPerPageTemplate="5,10"
paginatorPosition="bottom">
<p:columnGroup type="header">
<p:row>
<p:column rowspan="2" headerText="User" />
<p:column rowspan="2" headerText="Asset" />
<p:column colspan="6" headerText="Roles" />
<p:column rowspan="2" colspan="2" headerText="Action" />
</p:row>
<p:row>
<p:column headerText="Project Manager"></p:column>
<p:column headerText="Project Manager Deputy"></p:column>
<p:column headerText="Business Analyst"></p:column>
<p:column headerText="Functional Analyst"></p:column>
<p:column headerText="Technical Analyst"></p:column>
<p:column headerText="Developer"></p:column>
</p:row>
</p:columnGroup>
<p:column>
<h:outputText value="#{p.usercd}" />
</p:column>
<p:column>
<h:outputText value="#{p.asset}" />
</p:column>
<p:column colspan="6">
<h:panelGroup layout="block" >
<p:selectManyCheckbox columns="6" value="#{p.rolesList}">
<f:selectItems value="#{comBean.l_roles}" var="role" itemLabel="#{role}" itemValue="#{role}" />
</p:selectManyCheckbox>
</h:panelGroup>
</p:column>
<p:column>
<p:commandButton action="#{comBean.m_updateAccess}" ajax="false" icon="ui-icon-pencil">
<f:setPropertyActionListener value="#{p}" target="#{comBean.f_selectedUser}" />
<f:param name="area" value="project" />
</p:commandButton>
</p:column>
<p:column>
<p:commandButton action="#{ubean.m_deleteUser}" ajax="false" icon="ui-icon-trash">
<f:setPropertyActionListener value="#{p}" target="#{comBean.f_selectedUser}" />
<f:param name="area" value="project" />
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
Here the result:
How can I adapt content to header columns?
You are using tableStyle="width:auto" in your p:dataTable.
Removing this will align the checkboxes to its respective columns but you can notice that the columns are still a little bit misaligned.
To solve this, you can add style="padding:0px;" on your checkbox p:column.
Your code will look something like this.
<p:dataTable id="i_dtb2" var="p" value="#{comBean.l_uSrcRes}" paginator="true" rows="5" rowsPerPageTemplate="5,10"
paginatorPosition="bottom">
// other codes
<p:column colspan="6" style="padding:0px;">
// other codes
</p:column>
// other codes
</p:dataTable>
On another note, if your functional specification allows it, you can remove [Project Manager, Project Manager Deputy, etc] headers, since your are displaying them right next to the checkboxes.
You will have to remove p:columnGroup and set the headerText to their respective columns with "Roles" as headerText for your checkBox column.
Hope this helps.
Is there any simple way to unify look of dataTable inside rowExpansion and main dataTable? Or dou you have any ideas to make it nice?
I want it to looks like hidden rows of the same dataTable.
Here is how it looks by default:
And here is default xhtml code:
<p:dataTable id="cars" var="car" value="#{carBean.someList}">
<f:facet name="header">
List of Cars
</f:facet>
<p:column style="width:16px">
<p:rowToggler />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{car.user.name}" />
</p:column>
<p:columns value="#{scoresBean.otherList}" var="score" columnIndexVar="colIndex">
<f:facet name="header">
<h:outputText value="#{colIndex+1}" />
</f:facet>
<h:outputText value="#{car.scores[colIndex]}" />
</p:columns>
<p:rowExpansion>
<p:dataTable id="cycs" var="cyc" value="#{car.semiScoresList}">
<p:column>
<h:outputText value="#{cyc.partName}" />
</p:column>
<p:columns value="#{scoresBean.otherList}" var="score" columnIndexVar="col">
<h:outputText value="#{cyc.partsScores[col]}" />
</p:columns>
</p:dataTable>
</p:rowExpansion>
</p:dataTable>
You can't, not without a lot of css javascript etc. Use a p:treetable for this
I try to export some data loded from database.
With the code below, the exported file shows empty values in all columns althought my variable marchebean.selectedmarche.marchetraveau contains values.
Is there anything wrong in my code ?
I'm using Primefaces 4.0 and this is my xhtml page
<h:form id="form">
<p:tabView>
<p:tab title="Visualiser ">
<p:panel>
<h:commandLink >
<p:commandButton value="exporter" />
<p:dataExporter type="xls" target="crs" fileName="prixde" pageOnly="true" />
</h:commandLink>
<p:dataTable id="crs" var="marche" value="#{marchebean.selectedmarche.marchetraveau}" >
<f:facet name="header">
Tbaleau des travaux
</f:facet>
<f:facet name="footer">
<h3> Total HTVA = #{marchebean.calculdetotaltravhtva()}</h3>
<h3> Total TTC = #{marchebean.calculdetotaltravttc()} </h3>
</f:facet>
<p:column headerText="article" width="10%" >
<h:outputText value="#{marche.traveaux.article}"/>
</p:column>
<p:column headerText="Désignation des traveaux" width="40%" >
<h:outputText value="#{marche.traveaux.designation}"/>
<h:outputText value="#{marche.traveaux.paragraph}"/>
</p:column>
<p:column headerText="Unité">
<h:outputText value="#{marche.traveaux.unite}"/>
</p:column>
<p:column headerText="PUHTVA">
<h:outputText value="#{marche.prixunitaire}"/>
</p:column>
<p:column headerText="PUTTC">
<h:outputText value="#{marchebean.calcultva(marche.prixunitaire)}" />
</p:column>
<p:column headerText="Qtt">
<h:outputText value="#{marche.quantite}"/>
</p:column>
<p:column headerText="MHTVA">
<h:outputText value="#{marchebean.calculmonthtva(marche.prixunitaire ,marche.quantite)}" />
</p:column>
<p:column headerText="MTTC">
<h:outputText value="#{marchebean.calculmontttc(marche.prixunitaire ,marche.quantite)}" />
</p:column>
</p:dataTable>
</p:panel>
</p:tab>
</p:tabView>
</h:form>
we need to provide the
<f:facet name="header>
<h:outputText value="aricle"/>
</f:facet>
then exporter will add the headers to your exported document.
<p:column headerText="article" width="10%" >
<f:facet name="header">
<h:outputText value="article" />
</f:facet>
<h:outputText value="#{car.traveaux.article}"/>
</p:column>
This works for me. Maybe it needs validation and that's why it's empty at the end. Adding immediate="true" skips the validation.
<h:form id="confColaForm" .....>
<p:dataTable id="tablacolas" ... >
<f:facet name="header">
<h:commandLink id="exportar" update=":confColaForm:tablacolas" style="align:right;" immediate="true" >
<h:graphicImage library="images" name="iconexcel.png" style="width:30px;height:30px; "
title="Exportar" />
<p:dataExporter type="xls" target="tablacolas" fileName="ConfiguracionColas" />
</h:commandLink>
</f:facet>
...(columns here)
</p:dataTable/>
</h:form>
possible reason may be the "managedbean scope"...
1)change scope to "view"
2)serialize managedbean
this worked for me
Can we use a simple subtable inside another subtable?
I tried to use like this, but html is not generated.
I can get this done by using ui:repeat or p:dataGrid, but the issue is that the generated data table must be able to be exported to Excel & PDF with p:dataExporter. That is not supported in primefaces if we use it with anything other than dataTable.
Please help.
<p:dataTable id="tbl" value="#{storeReportsTransfer.drows}" var="i" >
<f:facet name="header">
<h:outputLabel value="Department Issue Report "/>
<h:outputLabel value="#{storeReportsTransfer.fromDepartment.name}"/>
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column headerText="Department" />
<p:column headerText="Category" />
<p:column headerText="Item" />
<p:column headerText="Rate" />
<p:column headerText="Total" />
</p:row>
</p:columnGroup>
<p:subTable value="#{i.categoryBillRows}" var="cbr" >
<f:facet name="header">
<h:outputText value="#{i.department.name}" />
</f:facet>
<p:column >
</p:column>
<p:column>
<h:outputText value="#{cbr.category.name}" />
</p:column>
<p:column>
<p:subTable value="#{cbr.itemBillRows}" var="ibr" >
<p:column>
<h:outputText value="#{ibr.item.name}" />
</p:column>
<p:column>
<h:outputText value="#{ibr.bill.netTotal}" />
</p:column>
<p:column>
<h:outputText value="#{ibr.bill.grantTotal}" />
</p:column>
</p:subTable>
</p:column>
<p:columnGroup type="footer">
<p:row>
<p:column footerText="Totals: " style="text-align:right"/>
<p:column footerText="#{cbr.bill.netTotal}" />
</p:row>
</p:columnGroup>
</p:subTable>
</p:dataTable>
I want to show a row only if I have data for it. The code which i have is:
<p:dataTable id="comments" var="comment"
value="#{agencyBean.getCommentByAgency(agencyBean.tAgency)}"
paginator="true" >
<p:column>
#{comment.author.name}
</p:column>
<p:column>
<c:if test="${not empty comment.positiveComment}">
<p:row>
<p:column>
<p:graphicImage library="images" name="positive.png" />
</p:column>
<p:column> #{comment.positiveComment} </p:column>
</p:row>
<br />
</c:if>
</p:column>
</p:dataTable>
But nevertheless I have data, the row is not shown. How can i implement this logic? Thanks!
Try to place the condition expression in the <p:row>'s tag itself, by using its rendered attribute :
<p:column>
<p:row rendered="#{not empty comment.positiveComment}">
<p:column>
<p:graphicImage library="images" name="positive.png" />
</p:column>
<p:column> #{comment.positiveComment} </p:column>
</p:row>
<br />
</p:column>