how to add a button to smart table
See original GitHub issuehow 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:
- Created 3 years ago
- Comments:7
Top 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 >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
Hey this is the link for the code
https://github.com/akveo/ng2-smart-table/blob/master/projects/demo/src/app/pages/examples/custom-edit-view/basic-example-button-view.component.ts
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() { }
}