selectManyCheckbox into p:dataTable column - jsf

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.

Related

primefaces datatable don't refresh correctly with column toggler

Users just noticed a big bug in my datatable. When you use a datatable and a column toggler, unselecting a column just shift some rows, but it goes wrong when some cells are empty.
So i tried to refresh my data table with
`<p:columnToggler datasource="datalist" trigger="toggler">
<p:ajax event="toggle" update="datalist"/>
</p:columnToggler>`
but it goes wrong with :
`<p:columns value="#{consultationView.columns}" var="column" columnIndexVar="colIndex"
visible="#{column.property.matches('Z06|Z07|Z09')}" >`
Because if i unselected a visible column it makes it visible again...
here is the full datatable :
`
<f:facet name="header">
<p:commandButton process="listFDP" icon="ui-icon-file-pdf" value="Editer les fiches de paie" action="#{consultationView.printPaieAgent()}" escape="false" ajax="false" onclick="this.form.target='_blank'" />
<p:commandButton id="toggler" type="button" value="Colonnes"
style="float:right" icon="ui-icon-calculator" />
<p:columnToggler datasource="datalist" trigger="toggler">
<p:ajax event="toggle" update="datalist"/>
</p:columnToggler>
</f:facet>
<p:column selectionMode="multiple" style="width:16px;text-align:center" exportable="false" toggleable="false" />
<p:column style="width:60px;text-align:left"
sortBy="#{row.gestion.datePaiement}" headerText="Pér. Paie" groupRow="true" sortOrder="ASCENDING" >
<h:outputText value="#{row.gestion.datePaiement}">
<f:converter binding="#{dateConverterMoisAnnee}" />
</h:outputText>
</p:column>
<p:column style="width:60px;text-align:left"
sortBy="#{row.gestion.dateOrigine}" headerText="Pér. Origine">
<h:outputText value="#{row.gestion.dateOrigine}">
<f:converter binding="#{dateConverterMoisAnnee}" />
</h:outputText>
</p:column>
<p:column headerText="N° cont." style="width:25px;text-align:center;white-space:pre-line;">
<h:outputText value="#{row.gestion.matricule.substring(10)}" />
</p:column>
<p:column headerText="Statut" style="width:150px;text-align:left;white-space:pre-line;" sortBy="#{row.statut}">
<h:outputText value="#{row.statut}" />
</p:column>
<p:columns value="#{consultationView.columns}" var="column" columnIndexVar="colIndex"
visible="#{column.property.matches('Z06|Z07|Z09')}" >
<f:facet name="header">
<h:outputText value="#{column.header}" />
</f:facet>
<h:outputText value="#{row.getRubValue(column.property)}" />
</p:columns>
</p:dataTable>`
Sorry Long post xs

cannot show header text of primefaces datatable

I have the below code, but find that the headerText doesn't show. Any advice?
<p:dataTable var="toDoList" value="#{dtView}" tableStyle="width:auto" >
<p:columnGroup type="header">
<p:row><p:column headerText="#{toDoList.schoolScrn}">
<p:outputLabel value="#{toDoList.schoolScrn}" />
</p:column></p:row>
</p:columnGroup>
<p:column>
<p:dataTable var="info" value="#{toDoList.infoList}" >
<p:column >
<h:outputText value="#{info}" />
</p:column>
</p:dataTable>
</p:column>
</p:dataTable>

p:columnGroup in p:pataTable does not show headerText

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>

IF statement does not work inside Primefaces 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>

<f:setPropertyActionListener> is called on first record of <p:subTable> only

Take a look at following code :
<p:accordionPanel id="accord" multiple="false" dynamic="true"
value="#{makelineMB.billNotYetGeneratedOrders}" var="orderList">
<p:tab title="#{makelineMB.getOrderTypeByList(orderList)}">
<p:dataTable var="sglOrd" value="#{orderList}">
<p:columnGroup type="header">
<p:row>
<p:column headerText="Item" />
<p:column headerText="Qty" />
<p:column headerText="Price" />
<p:column headerText="Kitchen Status" />
</p:row>
</p:columnGroup>
<p:subTable var="lineItem" value="#{sglOrd.orderLineItems}">
<f:facet name="header">
#{sglOrd.orderNo}
<p:spacer height="0" width="5" />
Total Amt: $#{sglOrd.total}
<p:spacer height="0" width="5" />
<p:commandButton id="cmdBtn_printBill" icon="ui-icon-print"
value="Collect Bill"
oncomplete="PF('printBill_dlg_widgetVar').show()"
update=":dailyorderform:printBill_dlg" style="float:right;">
<f:setPropertyActionListener
target="#{makelineMB.orderToPrint}" value="#{sglOrd}" />
</p:commandButton>
</f:facet>
<p:column>
<h:outputText value="#{lineItem.menuItemName.toUpperCase()}" />
</p:
<p:column>
<h:outputText value="#{lineItem.price}" />
</p:column>
<p:column>
<h:outputText
value="#{makelineMB.getOrderLineStatus(lineItem.status)}" />
</p:column>
</p:subTable>
</p:dataTable>
</p:tab>
</p:accordionPanel>
This code renders following UI :
Each tab contains order category and displays the orders in that category. Each order header having the <p:commandButton> and associated <f:setPropertyActionListener>.
However, the <f:setPropertyActionListener> get called on only first record of each tab other rendered orders collect bill <p:commandButton> does not fire <f:setPropertyActionListener>. How is this caused and how can I solve it?

Resources