I placed a p:selectBooleanCheckbox inside a p:dataTable in a JSF project.
When the cell is selected the check box floats to the right.
I know it's a css thing but i'm not sure how to fix it.
<p:cellEditor>
<f:facet name="output">
<p:selectBooleanCheckbox id="hasUserOutputCheckBox" value="#{customerBean.selectedReference.hasUser}"/>
</f:facet>
<f:facet name="input">
<p:selectBooleanCheckbox id="hasUserInputCheckBox" value="#{customerBean.selectedReference.hasUser}"/>
</f:facet>
</p:cellEditor>
The issue is that the editable table cell has a padding of 1rem (PrimeFaces 10, Saga theme) in output mode, but a padding of 0 in input mode. This is caused by the rule:
.ui-datatable .ui-datatable-data tr.ui-row-editing td.ui-editable-column {
padding: 0;
}
You can fix this difference by adding a padding of 1rem to your checkbox in input mode.
Tested with:
<p:dataTable value="#{testView.bools}" var="bool" editable="true">
<p:column headerText="bool">
<p:cellEditor>
<f:facet name="output">
<p:selectBooleanCheckbox value="#{bool}" disabled="true"/>
</f:facet>
<f:facet name="input">
<!-- Add padding here: -->
<p:selectBooleanCheckbox value="#{bool}" style="padding:1rem"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6rem">
<p:rowEditor/>
</p:column>
</p:dataTable>
Result:
Note that the actual padding you need to use might depend on the PrimeFaces version and the theme you are using. So, check the actual padding first using your browser's debugging tools.
See also:
How do I override default PrimeFaces CSS with custom styles?
Related
I would like to use a different background image rather than the default for specific treeNode.
<h:panelGroup id="tree-panel">
<p:tree
id ="tree"
value="#{processBean.root}"
var="sp"
dynamic="false"
cache="true"
animate="true"
selectionMode="single"
selection="#{processBean.selectedNode}"
rendered="#{processBean.renderTree}">
<p:treeNode type="csp" collapsedIcon="ui-icon-folder-collapsed"
expandedIcon="ui-icon-folder-open"
styleClass="jdhf">
<h:outputText value="#{sp}" />
</p:treeNode>
<p:treeNode type="ncsp" icon="ui-icon-document" >
<h:outputText value="#{sp}" />
</p:treeNode>
</p:tree>
</h:panelGroup>
.jdhf {
background-image: url("#{resource['primefaces-redmond/images/ui-icons_cd0a0a_256x240.png']}");
}
How can I change the style for the first node (csp)?
Thanks
This is a case where your selector is not specific enough. An example of specificity can be found here (including a clear explanation).
In this specific case, putting #tree in front of .jdhf in your css selector will solve it
So
#tree .jdhf {…}
This will do the job:
<p:treeNode type="ncsp" icon="ui-icon-document" styleClass="custom">
<h:outputText value="#{sp}" />
</p:treeNode>
.custom .ui-treenode-content .ui-icon {
background-image: url("#{resource['primefaces-redmond/images/ui-icons_cd0a0a_256x240.png']}");
}
I have a richdatatable in jsf .xhtml page . I have a very long text for a particular cell.
How can i set the width of the column and also display the text within the specified cell.
I am new to JSF and CSS. I am providing an example. Suppose I have two columns in a richdatatable and one of them have a very long text. I want that very long text to get displayed in lines(wrap text) rather than in a single line. I m not sure where, how and what to put as part of CSS
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ViewFileTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form>
<rich:dataTable value="#{fileController.feedbackFileItems}" var="item" id="table">
<rich:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListFeedbackTitle_feedbackPK_feedbackId}"/>
</f:facet>
<h:outputText value="#{item.feedbackPK.feedbackId}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListFeedbackTitle_department}"/>
</f:facet>
<h:outputText value="#{item.department}"/>
</rich:column>
</rich:dataTable>
</h:form>
</ui:define>
</ui:composition>
For displaying long text in multiple line you can use width attribute of rich:column:
<rich:column width="150" ...>
or the same for h:column:
<h:column width="110">
If you don't want to display text of datatable cell in multiple lines, then
1) you can use columnClasses attribute of rich:dataTable and specify no-wrap style for that column. For example combination
<rich:dataTable columnClasses="nowrap,">
with CSS
.nowrap {
white-space: nowrap;
}
will be resulted as table with non wrapped first column.
2) You can use style or styleClass attributes of rich:column for the same result (with the same CSS).
I have a set of subtables that is fed from the managed bean, and they may or may not have a header text.
<p:dataTable var="xxxxx" value="#{}" styleClass="xxxxx" emptyMessage="#{}">
<f:facet name="header">#{}</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column headerText="xxxxx" />
</p:row>
</p:columnGroup>
<p:subTable var="xxxxx" value="#{}">
<f:facet name="header">
<h:outputText rendered="#{}"
value="#{}" />
</f:facet>
<p:column style="text-align:center;">
<h:outputText value="#{}" />
</p:column>
</p:column>
</p:subTable>
</p:dataTable>
Only structure shown. Tag contents wiped on purpose.
when the subtable header is empty text, it still renders a thin empty header line. Is there any way I can supress the exibition of that header in case empty?
Using PF 3.5 on Tomcat 7 (mojarra)
Supress the exibition of the empty header of the subtable by using this CSS property:
td.ui-datatable-subtable-header:empty {
display: none
}
I'm using PrimeFaces 3.0-M3 and I have a <p:dataTable> with two columns in it. I want the first column to be fixed at a width of 20px. The other column can use whatever space is left over.
Here are screenshots of what I'm currently getting:
The first <p:column> seems to be ignoring the style setting that should have limited the width. It is sized way too big for the tiny coloured square that is the only content inside it and then the other column is pushed too far to the right.
Here is more of my Facelet code:
<p:dataTable
id="dataTableExpressions"
value="#{catconBean.userDefinedExpressionDataModel}"
var="currentRow"
emptyMessage="!! EMPTY TABLE MESSAGE !!"
selection="#{catconBean.userDefinedExpressionToEdit}"
selectionMode="single">
<p:ajax
event="rowSelect"
listener="#{catconBean.onUserDefinedExpressionRowSelect}"
update=":toolbarForm:catconToolbar" />
<p:ajax
event="rowUnselect"
listener="#{catconBean.onUserDefinedExpressionRowUnselect}"
update=":toolbarForm:catconToolbar" />
<p:column id="paletteColor" style="width:20px;">
<h:panelGroup
layout="block"
rendered="#{not empty currentRow.paletteColor}"
style="width:16px;height:16px;border:thin;border-style:solid;border-color:black;background-color:##{currentRow.paletteColor.RGB};" />
<h:panelGroup
layout="block"
rendered="#{empty currentRow.paletteColor}"
style="width:16px;height:16px;border:thin;border-style:dashed;border-color:red;background-color:white;text-align:center;">
<h:outputText value="?" style="color:red;font-weight:bold;" />
</h:panelGroup>
</p:column>
<p:column id="name">
<f:facet name="header">
<h:outputText value="#{bundle.catcon_label_CategoryName}" />
</f:facet>
<h:outputText
value="#{currentRow.name}"
style="#{not currentRow.definitionComplete ? 'color:red;' : ''}" />
</p:column>
</p:dataTable>
Can anyone tell me how to modify my Facelet code to make the first column have a fixed width of 20px?
In PrimeFaces 3.0, that style get applied on the generated inner <div> of the table cell, not on the <td> as you (and I) would expect. The following example should work out for you:
<p:dataTable styleClass="myTable">
with
.myTable td:nth-child(1) {
width: 20px;
}
In PrimeFaces 3.5 and above, it should work exactly the way you coded and expected.
This worked for me
<p:column headerText="name" style="width:20px;"/>
For some reason, this was not working
<p:column headerText="" width="25px" sortBy="#{row.key}">
But this worked:
<p:column headerText="" width="25" sortBy="#{row.key}">
I don't know what browser you're using, but according to w3schools.com, nth-child and nth-last-child do now work on MSIE 8. I don't know about 9. http://www.w3schools.com/cssref/pr_border-style.asp will give you more info.
can you try
<p:column width="20">
Inline styling would work in any case
<p-column field="Quantity" header="Qté" [style]="{'width':'48px'}">
I just did the following (in V 3.5) and it worked like a charm:
<p:column headerText="name" width="20px"/>
Addition to #BalusC 's answer. You also need to set width of headers. In my case, below css can only apply to my table's column width.
.myTable td:nth-child(1),.myTable th:nth-child(1) {
width: 20px;
}
I wanna switch the styles the datascroller uses to shows the selected page. Is it possible?
<f:facet name="footer">
<a4j:form>
<rich:datascroller styleClass="wrap-paginacao" for="estabelecimentoGrid" boundaryControls="hide" stepControls="show" fastControls="hide" >
<f:facet name="previous">
<h:graphicImage value="/home/img/previous.png"/>
</f:facet>
<f:facet name="next">
<h:graphicImage value="/home/img/next.png"/>
</f:facet>
</rich:datascroller>
</a4j:form>
</f:facet>
UPDATE
Default styles:
Styles I want:
override .rf-ds-act class of richfaces to whatever you want..
if this does not suffice you right click scroller component and click on inspect element using firebug you will get which css to override.