Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

html - Change style of <td> on ngModelChange using PrimeNG editable p-table

I am currently building an Angular application with PrimeNG as the UI Library. I have built a p-table with data and have made it editable with p-dropdowns. These p-dropdowns are binded to change the ngModel. I am having trouble changing the style of the td after making a change to the ngModel using the p-dropdown in the cell of the p-table.

Is there a way I can do this? I was thinking of either being able to style the td or the outputted div in the p-cellEditor. I'd like to change the style add a red border on the td on change of the ngModel.

Here is my code:

<p-table [value]="current.values">
  <ng-template pTemplate="body" let-value>
    <tr>
      <td pEditableColumn *ngFor="let field of fields" style="">
        <p-cellEditor>
          <ng-template pTemplate="input">
            <p-dropdown [options]="options" [(ngModel)]="value[field]" appendTo="body" 
            (ngModelChange)="value, field" required>
            </p-dropdown>
          </ng-template>
          <ng-template pTemplate="output">
            <div style="">
              {{value[field]}}
            </div>
          </ng-template>
        </p-cellEditor>
      </td>
    </tr>
  </ng-template>
</p-table>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...