【问题标题】:primeng data table columns width autofit based on contentsprimeng 数据表列宽度根据内容自动调整
【发布时间】:2020-07-15 13:56:35
【问题描述】:

我在我的角度应用程序中使用prime ng数据表,我想根据内容调整宽度而不给出固定宽度,它应该自动调整。谁能帮我这个?

<p-table #dataGrid [columns]="columns" [value]="data" [paginator]="columns.length > 0 ? paginator : false"
  [rowsPerPageOptions]="rowsPerPageOptions" [totalRecords]="totalRecords" [first]="first"
  [reorderableColumns]="true" [resizableColumns]="true" [(rows)]="rows" [lazy]="lazy" [lazyLoadOnInit]="false"
  (onLazyLoad)="loadData($event)" [loading]="loading" selectionMode="single" (onRowSelect)="rowSelect($event)"
  (onColReorder)="saveStateToSession()" (onPage)="paginationEvent();" [sortOrder]="sortOrder" [ngClass]="{'disabledrow':disabledRow}"
  (onRowReorder)="updatePriority($event)">
<!---Some data---->
</p-table>

【问题讨论】:

    标签: html css angular primeng


    【解决方案1】:

    这会对你有所帮助。

    &lt;p-table [resizableColumns]="true" [autoLayout]="true"&gt;

    【讨论】:

    • 如果我使用 [resizableColumns]="true" 那么列可以手动调整大小意味着我们可以调整列宽,但我希望它根据其中的内容调整宽度。
    • 如果我使用 [autoLayout]="true" 它不会显示全宽。
    • 你能用 html sn-p 更新你的问题吗?
    • 你现在可以检查一次吗?
    【解决方案2】:

    如果有人还在为此苦苦挣扎:

    请使用: [autoLayout]="true"

    但删除: [resizeableColumns]="true"[scrollable]="true"

    出于技术原因,可滚动和可调整大小的属性与 autoLayout 属性不兼容。每个人:AutoLayout not working in PrimeNG TurboTable

    这将为您提供与内容确定的一样宽的列。

    【讨论】:

      猜你喜欢
      • 2014-03-05
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-29
      相关资源
      最近更新 更多