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.

how to add a button to smart table

See original GitHub issue

how can i add a button in smart table. i found this link https://akveo.github.io/ng2-smart-table/#/examples/custom-editors-viewers where they integrated the button inside the cell, but i couldn’ find the code. i tried this code but it doesn’t work ` columns:

{ stat: { title: ‘stat’, type: ‘html’, valuePrepareFunction: (value) => { return <button nbButton>bouton</button>; } }, }`

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
mohammad0omarcommented, Jun 12, 2020

import { Component, OnInit, Input, Output, EventEmitter } from ‘@angular/core’; import { ViewCell } from ‘ng2-smart-table’;

@Component({ selector: ‘button-view’, template: <button (click)="onClickOne()">{{ renderValue }}</button> <button (click)="onClickTwo()">{{ renderValue }}</button> <button (click)="onClickThree()">{{ renderValue }}</button> , }) export class ButtonViewComponent implements ViewCell, OnInit { renderValue: string;

@Input() value: string | number; @Input() rowData: any;

@Output() clickOne: EventEmitter<any> = new EventEmitter(); @Output() clickTwo: EventEmitter<any> = new EventEmitter(); @Output() clickThree: EventEmitter<any> = new EventEmitter(); ngOnInit() { this.renderValue = this.value.toString().toUpperCase(); }

onClickOne() { this.clickOne.emit(this.rowData); } onClickTwo() { this.clickTwo.emit(this.rowData); } onClickThree() { this.clickThree.emit(this.rowData); } }

@Component({ selector: ‘basic-example-button-view’, template: <ng2-smart-table [settings]="settings" [source]="data"></ng2-smart-table> , }) export class BasicExampleButtonViewComponent implements OnInit {

settings = { columns: { id: { title: ‘ID’, }, name: { title: ‘Full Name’, }, username: { title: ‘User Name’, }, email: { title: ‘Email’, }, button: { title: ‘Button’, type: ‘custom’, renderComponent: ButtonViewComponent, onComponentInitFunction(instance) { instance.clickOne.subscribe(row => { alert(${row.name} saved!) }); instance.clickTwo.subscribe(row => { alert(${row.name} saved!) }); instance.clickThree.subscribe(row => { alert(${row.name} saved!) }); } }, }, };

data = [ { id: 1, name: ‘Leanne Graham’, username: ‘Bret’, email: ‘Sincere@april.biz’, button: ‘Button #1’, }, { id: 2, name: ‘Ervin Howell’, username: ‘Antonette’, email: ‘Shanna@melissa.tv’, button: ‘Button #2’, }, { id: 3, name: ‘Clementine Bauch’, username: ‘Samantha’, email: ‘Nathan@yesenia.net’, button: ‘Button #3’, }, { id: 4, name: ‘Patricia Lebsack’, username: ‘Karianne’, email: ‘Julianne.OConner@kory.org’, button: ‘Button #4’, }, { id: 5, name: ‘Chelsey Dietrich’, username: ‘Kamren’, email: ‘Lucio_Hettinger@annie.ca’, button: ‘Button #5’, }, ];

constructor() { }

ngOnInit() { }

}

Read more comments on GitHub >

github_iconTop Results From Across the Web

create Smart table with custom toolbar - SAP Community
i created a smart table but i need to add a custom tool bar that contains custom buttons such as "Add" button ,...
Read more >
Add custom button in actions column in ng2-smart-table in ...
In an ng2-smart-table in Angular 2 I want to add a new button in the actions column and by clicking on this button...
Read more >
sap.ui.comp.smarttable.SmartTable - Samples - Demo Kit
sap.ui.comp.smarttable.SmartTable ; Smart Table with custom buttons for personalization features (sort, filter..) SmartTable control with custom toolbar buttons ...
Read more >
Dynamically Row Components For Smart Table (forked)
Adding component dynamically into dynamic position and interact and pass data to and from it.
Read more >
Smart Table documentation - GitHub Pages
module('myApp',['smart-table'] to your angular application. Then use the markup you would normally do for html tables. On the table element add the st-table ......
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