How to put custom content like a linebreak inside p:column header

后端 未结 4 1290
执念已碎
执念已碎 2021-01-03 03:04

In my application, I have the following :

\"data

The 2nd column

相关标签:
4条回答
  • 2021-01-03 03:14

    Try this

    <f:facet name="header">
        <h:outputLabel value="Number of&#10;Sessions" style="white-space:pre;"/>
    </f:facet>
    

    If using the "Number of Sessions" from properties file, try the below in your properties file ...

    myString = Number of \
               Sessions
    
    0 讨论(0)
  • 2021-01-03 03:24

    If it's CSS, you could have a <br/> tag after 'Number of'. I just saw your edited post.

    What you're doing in Firebug is actually 'editing text' However, what you need to do is 'Right click' and then 'Edit HTML'. This way when you insert the
    tag, the text would break and shift onto the next line.

    0 讨论(0)
  • 2021-01-03 03:25

    First of all, you need to remove the headerText attribute from the column and add a header facet inside it:

    /*  no_of_sessions = Number of &#10; Sessions  */
    <p:column ... >
        <f:facet name="header">
            <h:outputText value="#{l10n.no_of_sessions}" 
                      escape="false" style="white-space:pre-line;" />
        </f:facet>
        ...
    </p:column>
    

    The escape="false" is relevant so html is escaped, then you can put anything you want in there. If you just want to style content, this is not needed

    0 讨论(0)
  • 2021-01-03 03:35

    The simplest answer for this is to add white-space:pre-line in the style attribute. See the below code

    <p:column headerText="Number of Sessions" style="white-space:pre-line;width:50px;">
         <h:outputText value="#{value}"></h:outputText>
    </p:column>
    
    0 讨论(0)
提交回复
热议问题