Custom cell view with click crashes
- Lingua principale
- TypeScript
- Stelle
- 1.6k
- Fork
- 867
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Hello,
I am trying to make a custom view for a column which will contain some buttons, which will execute a function. I found an example in the documentation. (https://github.com/akveo/ng2-smart-table/blob/master/src/app/pages/examples/custom-edit-view/basic-example-button-view.component.ts), but for unknown reasons the table will crash when it wants to render the custom cell.
This is the component:
```
import {Component, OnInit, Input} from '@angular/core';
import {ViewCell} from "ng2-smart-table";
@Component({
selector: 'action-button-view',
template: `
{{ renderValue }}
`,
})
export class ActionButtonViewComponent implements ViewCell, OnInit {
renderValue: string;
@Input() value: string | number;
constructor() { }
ngOnInit() {
this.renderValue = this.value.toString().toUpperCase();
}
showAlert() {
alert(this.renderValue);
}
}
```
In the settings of the table:
```
settings = {
columns: {
....
actions: {
title: 'Actions',
type: 'custom',
renderComponent: ActionButtonViewComponent,
},
},
actions: {
add: false,
edit: false,
delete: false
},
editable: false,
};
```
and creating the objects for in table:
```
this._ordersService.getCityOrders('Unpaid', (10 * 1000))
.subscribe(orders => {
let formattedData = [];
_.forEach(orders, (order) => {
var newObject = {
....
button: order.id
};
formattedData.push(newObject);
});
this.source.load(formattedData);
});
```
Thanks in advance.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.