Custom cell view with click crashes
See original GitHub issueHello,
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: `
<button (click)="showAlert()">{{ renderValue }}</button>
`,
})
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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
ios - My CollectionView with custom cells keeps crashing the ...
I'm trying to create a UICollectionView in which cells have textLabels in them, and the program compiles, runs ...
Read more >Crash when dequeueReusableCellWith… - Apple Developer
I take prototype cell in storyboard and assigned a custom class so there is no need to register class or nib in viewdidload....
Read more >Crash when using Date() in custom cell on Master / Detail
Look great and goes to the detail fine. Create 5 of them, and then delete one. It crashes every time you delete, on...
Read more >Excel not responding, hangs, freezes or stops working
For more information on startup folders used by Excel, see Customize how Excel ... If you are on Windows 8 or Windows 8.1,...
Read more >My App Crashed, Now What? - RayWenderlich.com
To add an exception breakpoint, open the Debug navigator and click the + in the navigator's lower left corner. Choose Exception Breakpoint… from ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
entryComponents, please update your module. with this: entryComponents:[ActionButtonViewComponent, ‘your table component’], but I am not quite clear about the ng key word ‘entryComponents’
just confirming @thewalk’s solution; adding the render component to entryComponents in my module did help!