Struggling with the ng2-smart-table library, I am facing challenges in passing values entered in the edit line to a custom component:
Refer to the code snippet below for passing Maximum and Minimum Temperature values to the SmartTableEditorFunctionsComponent when adding a new row in the table.
temperaturaMaxima: {
type: 'number',
title: 'Temperatura Máxima',
},
temperaturaMinima: {
title: 'Temperatura Mínima',
type: 'number',
},
temperaturaMedia: {
title: 'Temperatura Média',
type: 'number',
editor: {
type: 'custom',
component: SmartTableEditorFunctionsComponent,
valuePrepareFunction(instance) {
instance.save.subscribe();
},
},
},
Below is an image of the table: [enter image description here][1]
I added a button to retrieve the value but unable to do so. Component code:
export class SmartTableEditorFunctionsComponent extends DefaultEditor {
@Input() value: string | number;
@Input() rowData: any;
@Output() save: EventEmitter<any> = new EventEmitter();
constructor() {
super();
}
getPlaceholder(value: any) {
const id = value.column.temperaturaMaxima;
return id;
}
test() {
const id = this.rowData.temperaturaMaxima;
alert('TESTE' + id);
}
}
Template code of the component:
{{ cell.newValue }}
<input
type="number"
[(ngModel)]="cell.newValue"
[name]="cell.getId()"
[placeholder]="cell.getTitle()"
[disabled]="!cell.isEditable()"
(click)="onClick.emit($event)"
/>
<button (click)="test()">Retrieve Value
Seeking help from someone who can guide me through this issue. [1]: https://i.sstatic.net/4QF1Y.png