I have created a custom render component to add buttons to my ng2-smart-table. The buttons are displayed correctly, and I can perform the action. What I want now is to refresh the table when the action is completed.
How can I achieve this? I have added a subscriber in the settings and am emitting event from my Component, but from the settings, how can I call another function to perform refresh of source?
Below is the code: Settings:
TableSettings = {
columns: {
documentId: {
title: 'Document ID'
},
button: {
title: 'Task Actions',
type: 'custom',
renderComponent: CustomButtonComponent,
onComponentInitFunction :(instance: any) => {
instance.retry.subscribe(row => {
//TODO Refresh Table
});}
}
};
Custom Render Component:
export class CustomButtonComponent implements ViewCell, OnInit {
renderValue: string;
@Input() value: string | number;
@Input() rowData: any;
@Output() retry: EventEmitter<any> = new EventEmitter();
constructor(){}
onRetry() {
this.retry.emit(this.rowData);
}
}
I have tried writing this.source.refresh(), but get error that can't access property source of undefined.