I was using Primefaces 3.4. I recently upgraded to primefaces 4.0.
Below code was working fine in 3.4. However after I upgraded to 4.0, my table facet header doesn't align with the column headers.
<p:dataTable id="itunesTopSongsDt"
var="itunesTopSongsDtV"
value="#{applicationAccessMb.itunesTopSongsList}"
resizableColumns="false"
style="width: 600px; float: right; margin-right: 10px; margin-top: 0px;">
<f:facet name="header">
<p:row>
<p:column colspan="3">
<p:outputPanel style="float:left;">
<h:outputText id="itunesTopSongsDtHdr"
value="iTunes Top 10 Songs"/>
</p:outputPanel>
</p:column>
<p:column>
<p:outputPanel style="float:right;">
<p:selectOneMenu id="songsChartCountrySom"
value="#{applicationAccessMb.songChartCountry}"
effect="fade"
style="text-align: left">
<f:selectItems value="#{applicationAccessMb.reportCountry}"/>
<p:ajax process="songsChartCountrySom"
event="change"
listener="#{applicationAccessMb.getItunesTopSongsForCountry}"
update="itunesTopSongsDt"/>
</p:selectOneMenu>
</p:outputPanel>
</p:column>
</p:row>
</f:facet>
<p:column headerText="Rank"
width="30"
style="text-align: center;">
<h:outputText value = "#{itunesTopSongsDtV.rank}"/>
</p:column>
<p:column width="45">
<p:graphicImage url="#{itunesTopSongsDtV.imagePath}" width="45" height="45"/>
</p:column>
<p:column headerText="Artist"
width="200">
<h:outputText value = "#{itunesTopSongsDtV.artist}"
rendered="#{!itunesTopSongsDtV.itunesArtistLinkFound}"/>
<h:outputLink onclick="window.open('#{itunesTopSongsDtV.itunesArtistLink}',
'', 'left=5,top=5,width=1080,height=700,toolbar=1,resizable=1,scrollbars=1'); return false;"
rendered="#{itunesTopSongsDtV.itunesArtistLinkFound}">
<h:outputText value = "#{itunesTopSongsDtV.artist}"/>
</h:outputLink>
</p:column>
<p:column headerText="Title"
width="250">
<h:outputLink onclick="window.open('#{itunesTopSongsDtV.itunesLink}',
'', 'left=5,top=5,width=1080,height=700,toolbar=1,resizable=1,scrollbars=1'); return false;">
<h:outputText value = "#{itunesTopSongsDtV.title}"/>
</h:outputLink>
</p:column>
</p:dataTable>
See the pictures. Is there any setting I am missing which I need to do in primefaces 4.0
Thanks
Chirag
A very simple solution would be replace the outputPanel by an easy div with align
<div align="left">
<h:outputText id="itunesTopSongsDtHdr" value="iTunes Top 10 Songs"/>
</div>
Primefaces Datatable - 4.0
Remove all style
First Specified table size i.e 700px;
e.g <style="width:700px;float:left;">
or
Specified div
<div style="width:700px;">
<div>Write your Top ten album here </div>
<div>Write datatable here </div>
</div>
Related
I have done a dataTableFilter to create edit and delete items with search. Everything works fine until I do "Search as you Type", but when I add an item after doing a "Search as you type", the item is added in the database and the view, but if I click edit aginst it, it shows the values below it and when I press cancel, the added value disappears ! Again if I do search as you type the new item starts appearing.
I have been struggling with this for long, are there limitations in JSF primefaces ?
<p:dataTable id="itemTable" var="row"
value="#{itemBean.allitems}"
emptyMessage=" No itemue found" styleClass="borderless"
paginator="true" rows="10" paginatorPosition="bottom"
style="font-family:'Lato';font-size:12px;border:1px solid #d7d9b2"
widgetVar="cataTable"
filteredValue="#{itemBean.filtereditems}">
<f:facet name="header">
<div class="row">
<p:outputPanel>
<div class="col-lg-9"
style="margin-top: 6px; text-align: right; font-weight: bold">
<h:outputText value="Search all fields : " />
</div>
<div class="col-lg-3">
<p:inputText id="globalFilter"
onkeypress="if (event.keyCode == 13) {return false; }"
onkeyup="PF('cataTable').filter()"
styleClass="form-control txtFieldInput"
placeholder="Enter keyword" />
</div>
</p:outputPanel>
</div>
</f:facet>
<p:column headerText="itemue Name" filterBy="#{row.name}"
filterStyle="display:none" sortBy="name" filterMatchMode="contains"
style="width:8%;text-align: center">
<h:outputText value="#{row.name}" />
</p:column>
<p:column headerText="No.of subitems"
style="width:8%;text-align: center">
<h:outputText value="#{row.totalsubitems}" />
</p:column>
<p:column headerText="Description"
style="width:8%;text-align: center">
<h:outputText value="#{row.description}" />
</p:column>
<p:column headerText="Date(MM/DD/YYYY)"
style="width:8%;text-align: center">
<h:outputText value="#{row.toDate}">
</h:outputText>
</p:column>
<p:column headerText="Base URL" style="width:8%;text-align: center">
<h:outputText value="#{row.itemurl}" />
</p:column>
<p:column style="width:5%;text-align: center">
<f:facet name="header">Action</f:facet>
<p:commandButton ajax="true" icon="ui-icon-pencil" title="Edit"
update=":itemForm:updateitemData"
oncomplete="PF('updateitem').show()">
<f:setPropertyActionListener value="#{row}"
target="#{itemBean.selecteditem}" />
</p:commandButton>
<p:commandButton ajax="true" icon="ui-icon-trash" title="Deactive"
style="background-color:green" rendered="#{row.isActive == 'Yes'}"
actionListener="#{itemBean.deleteitem(row)}"
oncomplete="PF('itemDelete').show()">
</p:commandButton>
<p:commandButton ajax="true" icon="ui-icon-trash" title="Active"
style="background-color:red" rendered="#{row.isActive == 'No'}"
actionListener="#{itemBean.activateitem(row)}"
oncomplete="PF('activateitem').show()">
</p:commandButton>
</p:column>
</p:dataTable>
I want to show the details of a person with a dialog as shown on Facebook when the mouse is placed on a person's name.
I am using dialog framework in primefaces.
The dialog should display data that must be loaded when the mouse is placed on the person.
The problem is the dialog position:
<p:dataTable filterDelay="700" reflow="true" emptyMessage="No se encontraron elementos" widgetVar="tblist"
id="dataTableList" var="item" paginator="true" paginatorPosition="bottom"
rows="10" rowKey="#{item.idPersona}" value="#{listadoPersonasMB.listPersonas}" filteredValue="#{listadoPersonasMB.filterlistPersonas}">
<f:facet name="header">
Resultado de la búsqueda #{listadoPersonasMB.cantPerFilter}
</f:facet>
<p:ajax event="filter" oncomplete="handleLoadStart();"/>
<p:column style="width: 50px">
<p:graphicImage style="border-radius: 50%" alt="image" id="fotoPer" value="#{listadoPersonasMB.fotoPersonaTabla}" cache="false" width="100%">
<f:param name="personId" value="#{item.idPersona}" />
</p:graphicImage>
</p:column>
<p:column width="100%" headerText="Nombre y apellidos" sortBy="#{item.nombre}" style="text-align: left" filterBy="#{item.nombre} #{item.nombre2} #{item.apellidos} #{item.apellidos2}" filterMatchMode="contains">
<p:commandLink ajax="false" id="pict" action="#{mBDetallesPersona.detallesPersona(item.idPersona)}" onmouseover="showPersonDetail();">
<h:outputText value="#{item.nombre} #{item.nombre2} #{item.apellidos} #{item.apellidos2}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:remoteCommand id="rcomperson" name="showPersonDetail" process="#this"
actionListener="#{listadoPersonasMB.showPersonDetail}"
update=":form2:perDeta" oncomplete="PF('carOP').show('#{component.clientId}')"
/>
<p:overlayPanel widgetVar="carOP" showEffect="fade" hideEffect="fade">
<p:outputPanel id="perDeta">
<ui:include src="perDialog.xhtml" />
</p:outputPanel>
</p:overlayPanel>
I finally found the solution with overlayPanel, remoteCommand and some javascript code
xhtml
<p:dataTable filterDelay="700" reflow="true" emptyMessage="No se encontraron elementos" widgetVar="tblist"
id="dataTableList" var="item" paginator="true" paginatorPosition="bottom"
rows="10" rowKey="#{item.idPersona}" value="#{listadoPersonasMB.listPersonas}" filteredValue="#{listadoPersonasMB.filterlistPersonas}">
<f:facet name="header">
Resultado de la búsqueda #{listadoPersonasMB.cantPerFilter}
</f:facet>
<p:column style="width: 50px">
<p:graphicImage style="border-radius: 50%" alt="image" id="fotoPer" value="#{listadoPersonasMB.fotoPersonaTabla}" cache="false" width="100%">
<f:param name="personId" value="#{item.idPersona}" />
</p:graphicImage>
</p:column>
<p:column width="100%" headerText="Nombre y apellidos" sortBy="#{item.nombre}" style="text-align: left" filterBy="#{item.nombre} #{item.nombre2} #{item.apellidos} #{item.apellidos2}" filterMatchMode="contains">
<p:commandLink ajax="false" action="#{mBDetallesPersona.detallesPersona(item.idPersona)}" onmouseover="loadPersonDetalles('#{component.clientId}', #{item.idPersona});">
<h:outputText value="#{item.nombre} #{item.nombre2} #{item.apellidos} #{item.apellidos2}"/>
</p:commandLink>
</p:column>
<p:column headerText="Edad" sortBy="#{item.calculaEdad()}" style="text-align: right; width: 60px" sortFunction="#{utilMB.ordenarEnteros}">
<h:outputText value="#{item.calculaEdad()}"/>
</p:column>
<p:column filterBy="#{item.miembro eq true ? 'Sí' : 'No'}" headerText="Membresía" filterMatchMode="contains" style="width: 220px">
<h:outputText value="#{item.miembro eq true ? 'Sí' : 'No'}" />
<span> <p:commandButton rendered="#{mBLogin.siTieneFuncion('AdminPersonas')}" icon="fa fa-refresh Fs16 white" title="Cambiar"
actionListener="#{listadoPersonasMB.selectToSetMember(item)}" oncomplete="PF('newDialog').show()"/> </span>
</p:column>
<p:column style="text-align: center; width: 40px" rendered="#{mBLogin.siTieneFuncion('AdminPersonas')}">
<p:commandButton icon="fa fa-pencil Fs16 white" title="Modificar"
action="#{listadoPersonasMB.cargaPersonaModi(item.idPersona)}"/>
</p:column>
<p:column style="text-align: center; width: 40px" rendered="#{mBLogin.siTieneFuncion('AdminPersonas')}">
<p:commandButton icon="fa fa-trash Fs16 white" title="Dar Baja"
action="#{mBDeletePersona.detallesPersona(item.idPersona)}"/>
</p:column>
</p:dataTable>
<p:remoteCommand name="showPersonDetail" process="#this"
actionListener="#{listadoPersonasMB.showPersonDetail}"
update=":form2:perDeta" oncomplete="loadPanel();"/>
<p:overlayPanel widgetVar="carOP" my="right bottom" showEffect="fade" hideEffect="fade"
dismissable="true" hideEvent="onmouseout"
dynamic="true"
>
<p:outputPanel id="perDeta">
<ui:include src="perDialog.xhtml" />
</p:outputPanel>
</p:overlayPanel>
javascript code, send param to remoteCommand
<h:outputScript id="waypointScript" target="body">
var idcom = 0;
function loadPersonDetalles(idC, idPer) {
showPersonDetail([{name:'x', value:idPer}, {name:'y', value:20}]);
idcom = idC;
}
function loadPanel() {
PF('carOP').show(idcom);
}
</h:outputScript>
backingbean
public void showPersonDetail() {
try {
Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
this.idPerSeledtToDialog = Integer.valueOf(params.get("x"));
} catch (Exception e) {
JsfUtil.addErrorMessage(e, "Error: filterListener() " + e.getMessage());
}
}
I need to print a treeTable's content. The problem is that not all columns are displayed/printed. The treeTable have 4 columns and only 2 are printed (truncating)
How to print the complete treeTable's content? Is possible to customize page layout (portrait/landscape)?
<p:commandButton value="Print"
type="button"
icon="fa fa-print">
<p:printer target="treeTable" />
</p:commandButton>
<p:treeTable id="treeTable"
value="#{myMB.root}"
var="obj"
resizableColumns="true"
style="width:100%">
<p:column headerText="Column Label 1" style="width:40%">
<h:outputText value="#{obj.label1}" />
</p:column>
<p:column headerText="Column Label 2" style="width:20%">
<h:outputText value="#{obj.label2}" />
</p:column>
<p:column headerText="Column Label 3" style="width:20%;text-align: center;">
<h:outputText style="float: center;" value="#{obj.label3}" />
</p:column>
<p:column headerText="Column Label 4" style="width:20%">
<h:outputText style="float: left;" value="U$" rendered="#{not empty obj.label4}" />
<h:outputText style="float: right;" value=" #{obj.label4}" rendered="#{not empty obj.label4}" />
</p:column>
Primefaces 5.3 and Wildfly 10
[]'s
so I am using the printer from Primefaces, but it can not find the id of the datatable im trying to print. Anyone know why? I have removed some code for clarity. I also got the printer working on a different site but its not working here
<p:outputPanel id="topPanel" style=" display:block; height: 24%; float: top">
<h:form>
<p:growl id="messages" showDetail="true" />
<p:toolbar style="width: 100%">
<f:facet name="right">
<div style="float: right">
<p:commandButton actionListener="#{s.save}" value="Bearbeiten">
<f:param name="Bearbeiten" value="10" />
</p:commandButton>
<p:commandButton value="Drucken" type="button" icon="ui-icon-print">
<p:printer target="datatable"/>
</p:commandButton>
</div>
</f:facet>
</p:toolbar>
</h:form>
</p:outputPanel>
<p:outputPanel id="datatable" style="height: 50%">
<ui:insert name="datatable" />
<p:dataTable var="item" value="" paginator="true" rows="10" selection="" id="Datatable">
<p:column style="width:16px;text-align:center"/>
<p:column headerText="ID">
<h:outputText value="" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="" />
</p:column>
<p:column headerText="Vorname">
<h:outputText value="" />
</p:column>
</p:dataTable>
</p:outputPanel>
I am using Primefaces 5 and with a Group data table with more than 150 columns. I am trying to set each column width manually. I tried the threads here, but still primefaces is auto adjusting my column widths to show all columns in one screen without any horizontal scrolling. I am looking for one place to set the column width in px or %.
I am not sure how to approach with Group Heading.
I tried so far:
resizableColumns="true" style="table-layout: fixed"
Set style="width:auto" and
set in css:
.repoTab.ui-datatable table { width: auto !important; }
My xhtml here:
<h:form>
<p:dataTable id="userTable" value="#{userDAO.data}" var="ub"
binding="#{userBean.dataTable}" paginator="true" rows="500"
resizableColumns="true" style="table-layout: fixed">
<f:facet name="header">
<p:toolbar>
<!-- Header Codes Here -->
</p:toolbar>
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column colspan="3" headerText="Application" style="width:auto" />
<!-- <p:column colspan="6" headerText="Primary" width="100%" /> -->
</p:row>
<p:row>
<!-- ************ Application ************* -->
<p:column colspan="3" headerText="Key" style="width:auto" />
<!-- ************ Primary ************* -->
</p:row>
<p:row>
<!-- ************ Appl Key ************* -->
<p:column headerText="Id" width="50" />
<p:column headerText="F Name" width="150" />
<p:column headerText="L Name" width="150" />
</p:row>
</p:columnGroup>
<p:column headerText="Id" width="50">
<h:outputText value="#{userBean.dataTable.rowIndex+1}" />
</p:column>
<p:column headerText="First Name">
<h:outputText value="#{ub.firstName}" />
</p:column>
<p:column headerText="Last Name">
<h:outputText value="#{ub.lastName}" />
</p:column> -->
</p:dataTable>
</h:form>
</html>
Keep your table CSS style:
.ui-datatable table { width: auto !important; }
Remove the width attribute and set the min-width on the columns style:
<p:columnGroup type="header">
<p:row>
<!-- ... -->
</p:row>
<p:row>
<p:column headerText="Id" style="min-width: 50px;" />
<p:column headerText="F Name" style="min-width: 150px;" />
<p:column headerText="L Name" style="min-width: 150px;" />
</p:row>
</p:columnGroup>
Hope it helps.
I solved it by adding expandableRowGroups="true", then I could use the style property.
<p:dataTable expandableRowGroups="true" scrollable="true" >
<p:columnGroup type="header">
<p:row>
<p:column rowspan="2" headerText="txt" style="width:50px;" />
</p:row>
</p:columnGroup>
</p:dataTable>