Word wrap with resizable columns in PrimeFaces - jsf-2

I am using a PrimeFaces dataTable. I need the column headers to word-wrap and be resizable. Here are my issues:
When I do styleClass="wrap" resizableColumns="true", only resizable
is working.
When I do styleClass="wrap" resizableColumns="false", only word-wrap is working.
My code is:
<p:dataTable id="transitCycleHighLevelDataTable" var="record"
value="#{transitCycleMB.highLevel}" rowKey="#{record.group}"
paginator="true" paginatorPosition="bottom" rows="10"
styleClass="wrap" resizableColumns="true" scrollable="true"
scrollWidth="100%" scrollHeight="250"
rowsPerPageTemplate="10,20,50"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {RowsPerPageDropdown} {NextPageLink} {LastPageLink} {Exporters}"
currentPageReportTemplate="(Displaying {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})">

Adding this style to your dataTable will allow the column headers to wrap and the columns to remain resizable:
.ui-datatable thead th {
white-space: normal !important;
}
Note: This was tested and works on PrimeFaces 6.2.

Related

Primefaces dataTable with select and dragable rows, select fails when rows are reordered

I have a primefaces dataTable which is both select-able (single selection) and has draggable rows. I also need to select a row via a button (apart from being able to select the row itself). My view code is:
<p:dataTable id="itemTable" widgetVar="itemTable"
var="item" draggableRows="true"
value="#{routesModelBean.itemList}" selectionMode="single"
selection="#{routesModelBean.selectedItem}"
rowKey="#{item.id}" rowIndexVar="rowId">
<p:column style="width:32px;text-align: center">
<p:commandButton icon="ui-icon-search"
onclick="PF('itemTable').unselectAllRows();PF('itemTable').selectRow(#{rowId},false);" type="button">
</p:commandButton>
</p:column>
The problem seems to be the "rowIndexVar". For example, if i have two items in my list and i swap them by dragging, then clicking the button of one item will result in selecting the other.
Edit: Primefaces version is 6.0
When reordering the rows you should update the table too. Use the following
<p:ajax event="rowReorder" listener="YOUR_LISTENER" update=":itemTable" />

draggable and resizable attributes are not working for primefaces datatable

I have a datatable for displaying the result being originated on the basis of various parameters selected on the same panel. I have attached the snap-shot of datatable.
Datatable maybe containing multiple rows. It may look you all cluttered at this movement but I am trying to improve it.
I have tried to use draggable and resizable attributes of primefaces datatable as below but those are not working. I am not able to expand and drag the columns across the datatable:
<p:dataTable id="tbl" var="item"
value="#{cc.attrs.searchAndConsultSecuritiesEntriesResultsPanel.results}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
paginator="true" rows="20" style="margin-bottom:20px"
sortMode="multiple" draggableColumns="true" draggableRows="true"
resizableColumns="true">

Primefaces datatable with commandLink conflicts with row selection

I am working with PrimeFaces 5. The row selection is enabled and I want to embed a commandLink in one of the columns. When I click on the commandLink, I show a dialog, but I do not want the row to be selected. Is this possible (currently both events happen, the dialog is shown and the row is selected)?
<p:dataTable id="tableData" widgetVar="tableData" var="p"
value="#{bean.list}" ...
selection="#{bean.selectedItem}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{actionBean.onSelect}"
update="#form" onstart="PF('statusDialog').show();"
oncomplete="PF('statusDialog').hide();" />
<p:column headerText="Title" ...>
<p:commandLink id="clickableTitle" onstart="PF('statusDialog').show();"
oncomplete="PF('statusDialog').hide();PF('detailsDialog').show()">
<h:outputText value="#{p.title}" styleClass="link"/>
</p:commandLink>
</p:column>

Change default color of a popupPanel?

I have a popupPanel:
<rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Simple popup panel" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#" onclick="#{rich:component('popup')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<p>Any content might be inside this panel.</p>
<p>
The popup panel is open and closed from the javascript function of component client side object. The following code
hide this panel:
<f:verbatim>#</f:verbatim>{rich:component('popup')}.hide()
</p>
</rich:popupPanel>
I´m using this example:
Simple popup example
I want to change the color, the default color is blue, I want to change this color to Red or Green, is it possible ?
If it is relevant, i´m using richfaces 4.
Thanks in advance !
Add This css :
.rf-pp-hdr{
background: red;
}

rich:dataGrid borders issue rich faces 4

We are upgrading from jsf 1.2 to jsf 2.
We are using apache myfaces 2.1 and rich faces 4.3.
The issue is i am not able to get borders around <rich:dataGrid> component.
I have seen posts describing how to remove the borders but no one specifies how to get borders.
It seems that borders are by default rendered earlier (they were coming when rich faces 3 is used ) but after upgrading to rich faces 4 , ther are not rendered
by default.
Following is the xhtml snippet.
<rich:dataGrid value="#{bean.getListValues}" var="value" columns="1" rowKeyVar="index" id="qsns"
style="border-bottom-width:10px;">
<h:panelGrid id="qsn#{index+1}" border="10" columns="2">
<h:outputText value="qsn #{index+1}"/>
<h:selectOneMenu value="#{value.qsn}">
<f:selectItems value="#{bean.qsnPool}" />
</h:selectOneMenu>
<h:outputText value="Answer"/>
<h:inputText value="#{value.answer}"/>
</h:panelGrid>
</rich:dataGrid>
I also tried setting borders explicitely for panelGrid (border="10") in above snippet.
and to rich:dataGrid (border-bottom-width:10px), but it is not working as specified in url according to url : http://docs.jboss.org/richfaces/latest_4_2_X/Component_Reference/en-US/html/chap-Component_Reference-Tables_and_grids.html#sect-Component_Reference-Tables_and_grids-richlist
Can anyone please help ?
The border-bottom-width:10px; isn't working because the border-bottom-style is none.
The borders around <rich:datagrid> aren't defined on one element. The left and top borders are defined on the datagrid, class rf-dg. The bottom and right are defined on the grid cells, class rf-dg-c. You'll have to overwrite the classes if you want to change all the borders.
I am able to get the desired behavoiur by following changes
.tableClass1 .rf-dg-c{
border: 1px solid #000;
}
table.tableClass1.rf-dg{
border-collapse:collapse;
}
<rich:dataGrid value="#{bean.getListValues}" var="value" columns="1" rowKeyVar="index" id="qsns"
styleClass="tableClass1">
<h:panelGrid id="qsn#{index+1}" border="10" columns="2">
<h:outputText value="qsn #{index+1}"/>
<h:selectOneMenu value="#{value.qsn}">
<f:selectItems value="#{bean.qsnPool}" />
</h:selectOneMenu>
<h:outputText value="Answer"/>
<h:inputText value="#{value.answer}"/>
</h:panelGrid>
</rich:dataGrid>
With above style classes and xhtml code , borders are perfectly rendered.
First style sheet renders borders for grid cells and second style sheet collapses
the space between adjacent cell borders (since cellspacing attribute doesn't work for rich:dataGrid)
The above selectors apply only to local <rich:dataGrid> , that means not affecting globally for all <rich:dataTables>
The border attribute is not doing much, try using CSS styling:
<h:panelGrid style="border: 1px solid #000;"> ...
Or use CSS via classes:
<h:panelGrid styleClass="myClass"> ...
In your CSS:
.myClass {
border: 1px solid #000;
}

Resources