Overflow text in primeNg DataTabel cell
Asked Answered
P

2

6

I want to hide overflow text in a DataTable cell primeNg, but nothing seems to work. I didn't find anything on their documentation that could help me.

  <p-dataTable #dataTable 
tableStyleClass="defaultDataTable"
[value]="rows | async"
resizableColumns="false"
reorderableColumns="true" 
responsive="true"
[rowHover]="true" 
[(selection)]="selectedRows"
[rowStyleClass]="getRowClass" 
[loading] = "loading"
(onRowClick)="onSelect($event)" 
(onRowSelect)="onSelect($event)" 
(onRowUnselect)="onSelect($event)"
(onRowDblclick)="onRowDblclick($event)" 
(onHeaderCheckboxToggle)="checkAll($event)">
<p-footer class="table-footer p-text-muted" *ngIf="showFooter">
  <ng-container i18n> {{footerText}}: {{dataTable?.dataToRender?.length || 0}} </ng-container>
</p-footer>
<p-column *ngIf="hasCheckboxColumn == true" [field]="IsSelected" [header]="" selectionMode="multiple"
  onclick="checkAll($event)" [sortable]="false" ></p-column>
      <p-column *ngFor="let column of columns" [field]="column.prop" [style] = "{width: '20%'}" [header]="column.name" [hidden]="!column.visible" [sortable]="isLockColumn(column.name) == false"  >
          <ng-template let-col let-row="rowData" pTemplate="body">
            <div *ngIf="isValueBoolean(row[col.field]); else renderValue" align="center" title=" ">
              <md-checkbox [(ngModel)]="row[col.field]" (change)="lockColumnChecked($event, row)" style = "width:20%;text-overflow: ellipsis;" [disabled]="true"></md-checkbox>
            </div>
            <ng-template #renderValue style = "width:20%;text-overflow: ellipsis;"><span style = "width:20%;text-overflow: ellipsis;" [mdTooltip]="getTooltip(row, column)" mdTooltipPosition="before">{{row[col.field]}}</span></ng-template>
          </ng-template>
          <ng-template *ngIf="isLockColumn(column.name)" pTemplate="header">
            <div class="lock-header">
              <md-checkbox [(ngModel)]="headerSelectClicked" (click)="changeStateOfRows(headerSelectClicked, rows, 'IsLocked')" class="lock-header-checkbox"></md-checkbox>
              <i class="fa fa-lock fa-1x" aria-hidden="true"></i>
            </div>
          </ng-template>
        </p-column>

enter image description here

Pumice answered 4/9, 2017 at 8:41 Comment(6)
Image is not available in attachment...but if overflow:ellipsis is not working then use word-wrap: break-word;Inbeing
Try defining global class in style.css as -defaultDataTable {word-wrap: break-word;}Xuthus
No, it didn't work...I am so frustratedPumice
By default it would be hidden...datatable uses CSS property overflow:hidden. Can you please try to attach your image or any plunker demoInbeing
1drv.ms/i/s!AgNenwMMyZRWg4tNRzRRcYMdqQa7-QPumice
have you used style property in column like this : <p-column field="Col2" header="Column 2" [style]="{'width': '200px','overflow': 'hidden'}"></p-column>. And also dont'use text like "sssssssssssssssssssssssssssss" this. take some real time text.Inbeing
P
22
 .ui-datatable-data> tr> td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

this is the final solution...Thank you guys !

Pumice answered 4/9, 2017 at 10:18 Comment(2)
@Filip Is there any way you can do it for an individual column only?Demott
@MurginBoo Have you try something like : .ui-datatable-data> tr> td:nth-child(2) { // css }Pumice
S
0

Just add the style for white-space in p-column. that worked for me.

Stair answered 31/10, 2018 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.