How update row background colour when row updated in ng-prime datatable for dynamic columns?

怎甘沉沦 提交于 2020-01-14 02:43:10

问题


I want to change row colour when row updated.how set row background colour when record is updated successfully . .html

<p-dataTable emptyMessage="{{tbldatamsg}}" 
      [value]="dataset" scrollable="true" 
      [style]="{'overflow':'hidden!important'}"  
      [responsive]="true" [stacked]="stacked" [filters]="GlobalFilterValue" [rows]="20" sortMode="multiple" [(selection)]="selectedRow"
       selectionMode="multiple"
      [resizableColumns]="true" columnResizeMode="expand" 
      [paginator]="true" 
      [globalFilter]="gb" 
      [rowsPerPageOptions]="[10,15,20,25]"
        appendTo="body" #dt>
        <p-column styleClass="checkbox ui-resizable-column" [style]="{'width': 'auto'}" selectionMode="multiple"></p-column>
        <p-column *ngFor="let col of cols;let j=index;"
         [style]="{'width':'130px','display':col.display} " 
          [field]="col.field" 
         [header]="col.header"
         [sortable]="true" 
         [filter]="true" filterPlaceholder="Search" (mouseleave)="hoveredIndex=null" filterPlaceholder="Search"
          appendTo="body">
        </p-column>
   </p-dataTable>

回答1:


Solved I have used data table attribute and pass function name.

[rowStyleClass]="lookupRowStyleClass"

.HTML

<p-dataTable emptyMessage="{{tbldatamsg}}" 
      [value]="dataset" scrollable="true" 
      [style]="{'overflow':'hidden!important'}" 
      [rowStyleClass]="lookupRowStyleClass"     
      [responsive]="true" [stacked]="stacked" [filters]="GlobalFilterValue" [rows]="20" sortMode="multiple" [(selection)]="selectedRow"
       selectionMode="multiple"
      [resizableColumns]="true" columnResizeMode="expand" 
      [paginator]="true" 
      [globalFilter]="gb" 
      [rowsPerPageOptions]="[10,15,20,25]"
        appendTo="body" #dt>
        <p-column styleClass="checkbox ui-resizable-column" [style]="{'width': 'auto'}" selectionMode="multiple"></p-column>
        <p-column *ngFor="let col of cols;let j=index;"
         [style]="{'width':'130px','display':col.display} " 
          [field]="col.field" 
         [header]="col.header"
         [sortable]="true" 
         [filter]="true" filterPlaceholder="Search" (mouseleave)="hoveredIndex=null" filterPlaceholder="Search"
          appendTo="body">
        </p-column>
   </p-dataTable>

.ts

 /* Function for set css for updated rows */
  lookupRowStyleClass(rowData) {
    return rowData['modified']==='U' ?'ui-widget-updated-row':'ui-widget-NoUpdated-row';
  }

.scss

//Updated row
::ng-deep .ui-datatable tbody > tr.ng-star-inserted.ui-widget-updated-row{
    background-color:$updated-row-color;
} 


来源:https://stackoverflow.com/questions/51039060/how-update-row-background-colour-when-row-updated-in-ng-prime-datatable-for-dyna

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!