akveo / akveo/ng2-smart-table

Custom cell view with click crashes

Abierto
#297 5 comentarios 0 reacciones 0 asignados Ver en GitHub
help wanted question
Lenguaje dominante
TypeScript
Estrellas
1.6k
Forks
867
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.