I'm using ng2-smart-table
as a table in my project.You can see it in below.
However I want to add a custom button named view
for this at end of the each row of table. As well as I want to open a new component when click the view
button. Then what i should do for this. I tried as follows. but not success.
add: {
addButtonContent: '<i class="nb-plus"></i>',
createButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmCreate: true
},
edit: {
editButtonContent: '<i class="nb-edit"></i>',
saveButtonContent: '<i class="nb-checkmark"></i>',
cancelButtonContent: '<i class="nb-close"></i>',
confirmSave: true
},
delete: {
deleteButtonContent: '<i class="nb-trash"></i>',
confirmDelete: true
},
view:{
viewButtonContent:''
},
Define settings like this.
settings = {
columns: {
name: {
title: 'Title',
},
description: {
title: 'Description',
},
customColumn: {
title: 'Actions',
type: 'custom',
filter: false,
renderComponent: MyCustomComponent,
onComponentInitFunction(instance) {
//do stuff with component
instance..subscribe(data=> console.log(data))
}
...
And define new button component like this,
@Component({
selector: 'll-button-comp',
template: ` <button (click)="click.emit(rowData)"> my button</button> `
})
export class MyCustomComponent implements OnInit{
@Input() rowData: any;
@Output() click:EventEmitter<any> = new EventEmitter(this.rowData);
ngOnInit(){
}
}
Note that rowData
(object of the selected row) is passed to the component which rows that instance belongs