简体   繁体   English

JSF rich:datatable列在多行中显示很长的文本

[英]JSF rich:datatable column display very long text in multiple lines

I have a richdatatable in jsf .xhtml page . 我在jsf .xhtml页面中有一个richdatatable。 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. 我是JSF和CSS的新手。 I am providing an example. 我提供一个例子。 Suppose I have two columns in a richdatatable and one of them have a very long text. 假设我在richdatatable中有两列,其中一列有很长的文本。 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 我不确定将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属性:

<rich:column width="150" ...>

or the same for h:column : 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. 1)您可以使用rich:dataTable columnClasses属性,并为该列指定无包装样式。 For example combination 例如组合

<rich:dataTable columnClasses="nowrap,">

with CSS 用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). 2)您可以将rich:column stylestyleClass属性用于相同的结果(使用相同的CSS)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM