question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom cell view with click crashes

See original GitHub issue

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: `
    <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:open
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
thewalkcommented, Apr 30, 2017

entryComponents, please update your module. with this: entryComponents:[ActionButtonViewComponent, ‘your table component’], but I am not quite clear about the ng key word ‘entryComponents’

0reactions
hzitouncommented, May 9, 2017

just confirming @thewalk’s solution; adding the render component to entryComponents in my module did help!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found