akveo / akveo/ng2-smart-table

How to call a component with a button which is in a ng2-smart-table

オープン
#1,036 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
1.6k
フォーク
867
PR マージ指標
30日以内にマージされた PR はありません

説明

I have a ng2-smart-table which have a specific column with a button:

``

```typescript
settings = {
actions: {
position: 'right',
delete: false,
add: false
},
description: {
title: 'Description',
filter: false
},
.
.
.
id: {
title: 'Facility Rules',
type: 'custom',
renderComponent: ButtonRenderComponent,
onComponentInitFunction(instance) {
instance.save.subscribe( () => {
//something to call another component (so execute its
//ngOnInit() )...
});
}
```
I could not add a button directly, so i created another component for the button. Below is my button component:

```typescript
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

@Component({
template: `click me`,
selector: 'button-render',
providers: []
})
export class ButtonRenderComponent implements OnInit {

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

@Output() save: EventEmitter = new EventEmitter();

ngOnInit(): void {
console.log(this.value)
}

onClick() {
this.save.emit();
}
}
```
When the button of one of the rows is clicked the ng2 table should disappear and the other component should be displayed. Or another solution is to display the component called below/after the ng2 smart table in DOM.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。