a657a000aaa45782cf490d4170c3ab052a2d6afe
[portal/sdk.git] /
1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2
3 @Component({
4   selector: 'rdp-select-editor',
5   styleUrls: ['./rdp-select-editor.component.scss'],
6   template: `
7     <mat-select [(value)]="selected" 
8     (selectionChange)="detectChange(columnValue)">
9       <mat-option *ngFor="let item of data" [value]="item.name">
10       {{item.name}}
11       </mat-option>
12     </mat-select>
13   `
14 })
15 export class RdpSelectEditorComponent implements OnInit {
16
17   @Input() rowdata: any;
18   @Input() columntitle: any;
19   @Input() data: any[];
20   @Output() changedColumnValue = new EventEmitter<any>();
21   selected: any;
22   columnValue: any;
23
24   constructor() { }
25
26   ngOnInit() {
27     if (this.rowdata != null || this.rowdata != undefined) {
28       let rowObj = JSON.parse(this.rowdata);
29       let column = this.columntitle;
30       this.columnValue = rowObj[column];
31       
32     } else {
33       this.columnValue = null;
34     }
35     this.selected = this.columnValue;
36     console.log(" this.selected :::", this.selected);
37   }
38
39   detectChange(changedValue) {
40     this.changedColumnValue.emit(changedValue);
41   }
42
43 }