In my application I am using akveo/ng-2-smart-table
. In one of its column I use custom component with select
HTML element to select an item from my data. When I select an element, I would like to update value of another cell in its row.
How can I do it?
For example, this is my component:
@Component({
selector: 'ngx-template-field-select',
template: `
<div class="form-group">
<select
name="fields"
class="form-control"
(change)="onChange()">
<option *ngFor="let field of fields"
[value]="field.id">{{ field.name }}</option>
</select>
</div>
`,
})
export class EditTemplateFieldComponent extends DefaultEditor implements OnInit {
@Input()
public value: string;
@Input()
public rowData: any;
public fields = [];
constructor(
public fieldsService: FieldsService,
) {
super();
}
public ngOnInit(): void {
this.fieldsService.getEntityList().subscribe(
(value: FieldType[]) => {
this.fields = value;
});
}
onChange() {
this.cell.setValue(this.value);
}
}