2017-10-18 8 views

答えて

0

をプレビューするには 使用このリンクは、以下の手順に従うことができます。 1.スマートテーブルコンポーネントをモジュールにインポートします。 "Local DataSource" from "ng2-smart-table"をインポートします。

2.クラスに次のコードを追加します。

 @Component({ 
     selector: 'my-app', 
     template: ` 
     <div> 
      <h2>Hello {{name}}</h2> 
      <button (click)="addColumn()">Add Column</button> 
      <ng2-smart-table [settings]="settings" [source]="source"></ng2-smart-table> 
     </div> 

     `, 
    }) 
    export class ResultComponent implements OnInit 
     { 
     source: LocalDataSource; 
     i = 0; 
     settings; 
     mySettings = { 
     mode: 'inline', 
     actions: { 
      delete:false, 
     }, 
     add: { 
     confirmCreate: true, 
     }, 
     delete: { 
     confirmDelete: true, 
     }, 
     edit: { 
     confirmSave: true, 
     }, 
     columns: { 

     } 
     }; 

    //method that adds the column. You can use trigger events to do this 
    public addColumn() { 
      this.mySettings.columns["new column " + this.i] = { title: 'new column 
     ' + this.i.toString()}; 
      this.settings = Object.assign({}, this.mySettings); 
      this.i++; 
     } 

    } 
関連する問題