I'm using ui:repeat regularly in p:dataTable in a <p:columnGroup type="header">, mostly to set the colspan attribute which works fine. Examples below are simplified to concentrate on the issue.
<p:dataTable var="i" value="#{bean.data}">
<f:facet name="header">Works fine</f:facet>
<p:columnGroup type="header">
<p:row>
<ui:repeat var="c" value="#{bean.columns}">
<p:column colspan="1" headerText="#{c.name}" />
</ui:repeat>
</p:row>
</p:columnGroup>
<p:column><h:outputText value="#{i.value}"/></p:column>
</p:dataTable>
Now let's come to p:treeTable and issue. A example with p:columnGroup is also working fine:
<p:treeTable var="i" value="#{reportPlanningMtefBean.tree}">
<f:facet name="header">columnGroup fine in tree</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column colspan="1" headerText="a" />
<p:column colspan="1" headerText="b" />
</p:row>
</p:columnGroup>
<p:column><h:outputText value="#{i.value1}"/></p:column>
<p:column><h:outputText value="#{i.value2}"/></p:column>
</p:treeTable>
But I have no success with a ui:repeat in p:treeTable. The headers are simply not shown!
<p:treeTable var="i" value="#{reportPlanningMtefBean.tree}">
<f:facet name="header">columnGroup fine in tree</f:facet>
<p:columnGroup type="header">
<p:row>
<ui:repeat var="c" value="#{bean.columns}">
<p:column colspan="1" headerText="#{c.name}"/>
</ui:repeat>
</p:row>
</p:columnGroup>
<p:column><h:outputText value="#{i.value1}"/></p:column>
<p:column><h:outputText value="#{i.value2}"/></p:column>
</p:treeTable>
Above examples are tested with PrimeFaces 5.2 (changed this to 6.0, too) and Mojarra 2.1.28-jbossorg-5.
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.
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>
i have a problem with p:column instead c:foreach
when i show size of list in p:column value found
but when i used p:column instead c:foreach result is empty
<h:form id="frmDataTable">
<p:dataTable widgetVar="widgetVarCrudDataTable" var="list"
id="dataTable"
value="#{workshiftListBean.listWorkshiftRqDtl}"
emptyMessage="No record found">
<p:columnGroup type="header">
<p:row>
<c:forEach items="#{workshiftListBean.listVoHeader}"
var="listHeader">
<p:column headerText="#{listHeader.headerDays}"
styleClass="#{listHeader.weekendStyle}" />
</c:forEach>
</p:row>
<p:row>
<c:forEach items="#{workshiftListBean.listVoHeader}"
var="listHeader">
<p:column headerText="#{listHeader.headerDates}"
styleClass="#{listHeader.weekendStyle}" />
</c:forEach>
</p:row>
</p:columnGroup>
<!--size found -->
<p:column>
#{list.listVoShift.size()}
</p:column>
<!-- but when i used c:foreach this result is empty -->
<c:forEach items="#{list.listVoShift}" var="shift">
<p:column>
<p:inputText value="#{shift.property}" />
</p:column>
</c:forEach>
my code problem in :
#{list.listVoShift.size()}
<!-- but when i used c:foreach this result is empty -->
<c:forEach items="#{list.listVoShift}" var="shift">
<p:column>
<p:inputText value="#{shift.property}" />
</p:column>
</c:forEach>
Try this
<ui:repeat var="shift" value="#{list.listVoShift}">
<p:column>
<p:inputText value="#{shift.property}" />
</p:column>
</ui:repeat>
I got a <p:treeTable> that works perfectly as showcase, I open a dialog to see the detail of each node... the dialog have a <h:selectOneMenu> and it's not working. I don't know why, send me the error "Target Unreachable" but if I put the attribute into a <h:outputText> it's working (it means that it's not null). What is happening?
<p:row>
<p:column colspan="4" style="width:800px">
<p:dialog id="edit" widgetVar="edit" header="Edit" showEffect="clip"
hideEffect="explode" position="center,center" width="520" modal="true" closable="false"
closeOnEscape="true" resizable="false" dynamic="true">
<h:panelGrid width="100%">
<p:row>
<p:column >
Name
</p:column>
<p:column>
<p:inputText value="#{levelBean.selectedLevel.name}" />
</p:column>
</p:row>
<p:row>
<p:column >
Description
</p:column>
<p:column>
<p:inputText value="#{levelBean.selectedLevel.description}" />
</p:column>
</p:row>
<p:row>
<p:column >
Level
</p:column>
<p:column>
<!-- this its showing OK !! -->
<h:outputText value="#{levelBean.selectedLevel.id.idLevel}"/>
<!-- this mark target unreachable -->
<h:selectOneMenu id="cbo" style="width=200px"
value="#{levelBean.selectedLevel.id.idLevel}" >
<f:selectItems value="#{cboLevelBean.list}" var="levelEdit"
itemValue="#{levelEdit.id.idNivel}"
itemLabel="#{levelEdit.name}"
/>
</h:selectOneMenu>
</p:column>
</p:row>
</h:panelGrid>
</p:dialog>
<p:treeTable id="treeTableLevels" value="#{levelBean.root}" var="subLevel" style="width:800px">
<f:facet name="header">
Levels
</f:facet>
<p:column headerText="#{subLevel.object.levelName}">
<h:outputText value="#{subNivel.object.nameSubLevel}" />
</p:column>
<p:column style="width:24px">
<p:commandLink update=":levelsForm:edit" oncomplete="PF('edit').show()" title="Level Detail" styleClass="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{subLevel}" target="#{levelBean.selectedLevel}" />
</p:commandLink>
</p:column>
</p:treeTable>
</p:column>
</p:row>
Thanks for any help!!
I fond the reason... I just put the selectonemenu into another form and it works.. but I don't know why.. can somebody explain?
<h:form id="someform">
<p:selectOneMenu id="cbo" style="width: 200px"
value="#{levelBean.selectedLevel.id.idLevel}">
<f:selectItems value="#{cboLevelBean.list}" var="levelEdit"
itemValue="#{levelEdit.id.idNivel}"
itemLabel="#{levelEdit.name}"/>
</p:selectOneMenu>
</h:form>
Anyway hope this help to others!
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>