gpt4 book ai didi

Primefaces 数据表列宽不起作用

转载 作者:行者123 更新时间:2023-12-04 18:45:19 28 4
gpt4 key购买 nike

我创建了一个包含一些测试数据的数据表。我的问题是某些值对于我的一列来说太大了,这导致了奇怪的布局:

enter image description here

(在订单栏之后应该显示另外两栏)

我已经尝试了一些东西:

  • <p:column headerText="Orders" width="50">没有变化
  • <p:column headerText="Orders" style="max-width: 30px;">使列更小,但值在 30px 后被削减
  • 在几个数字后添加 <br/>强制使用隔断线,但没有变化

  • 订单值是一个大字符串。我的目标是将订单列更改为字符串值被拆分的多行列。

    我的数据表代码:
    <h:body>
    <h:head>
    </h:head>
    <h:form id="form">
    <p:dataTable id="customerTable" var="customer" value="#{customerDataTable.allCustomer}"
    rows="25" paginator="true" emptyMessage="No customer found.">

    <p:column headerText="Customer ID" style="text-align: center;">
    <h:outputText value="#{customer.customerNumber}" />
    </p:column>

    <p:column headerText="Fist Name" style="text-align: center;">
    <h:outputText value="#{customer.contactFirstName}" />
    </p:column>

    <p:column headerText="Last Name" style="text-align: center;">
    <h:outputText value="#{customer.contactLastName}" />
    </p:column>

    <p:column headerText="Sales Employee Nr." style="text-align: center;">
    <h:outputText value="#{customer.employee.employeeNumber}" />
    </p:column>

    <p:column headerText="Orders">
    <h:outputText value="#{customer.allOrders}"/>
    </p:column>


    <p:column headerText="Payments" style="text-align: center;" >
    <p:commandButton id="payment_btn" update=":form:p_display" oncomplete="paymentDialog.show()" icon="ui-icon-calculator">
    <f:setPropertyActionListener target="#{customerDataTable.selectedCustomer}" value="#{customer}"/>
    </p:commandButton>
    <p:tooltip for="payment_btn" value="Click to see all payments" showEffect="fade" hideEffect="fade"></p:tooltip>
    </p:column>

    <p:column headerText="Contact Data" style="text-align: center;" >
    <p:commandButton id="contact_btn" update=":form:c_display" oncomplete="contactDialog.show()" icon="ui-icon-home">
    <f:setPropertyActionListener target="#{customerDataTable.selectedCustomer}" value="#{customer}"/>
    </p:commandButton>
    <p:tooltip for="contact_btn" value="Click to see the detailed contact data" showEffect="fade" hideEffect="fade"></p:tooltip>
    </p:column>

    </p:dataTable>
    </h:form>
    </h:body>

    在其他线程中,我找到了使用 css 的解决方案,但这也不起作用(原因可能是我现在不知道如何以及在何处创建 css 文件和方法)。

    最佳答案

    如果您希望行中断,您可以使用 CSS。尝试将其添加到您的样式中

    .ui-datatable td,.ui-datatable th {
    white-space: normal;
    }

    如果文本中没有空格,这将不起作用,因为浏览器不知道在哪里换行,在这种情况下,您可以使用 wbr 标签,但重要的是要说它不受 IE 支持

    另见:
  • http://www.w3schools.com/tags/tag_wbr.asp
  • 关于Primefaces 数据表列宽不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15547735/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com