添加数据后如何用新数据加载ng2-smart-table?

时间:2019-11-14 09:48:38

标签: angular typescript ng2-smart-table

每当我向表中添加新数据时,表应自动加载。数据被加载到数据库。但是该表不会更新。有没有办法做到这一点?

myHtmlPage.html

<ng2-smart-table [settings]="progressTable_Config" 
                 [source]="progressTableSource"
                 (createConfirm)="addProgressRecord($event)" 
                 (deleteConfirm)="onDeleteConfirm($event)">

myComponentFile.ts

progressTable_Config = {
    add: {
      addButtonContent: '<i class="nb-plus"></i>',
      createButtonContent: '<i class="nb-checkmark"></i>',
      cancelButtonContent: '<i class="nb-close"></i>',
      confirmCreate: true,
    },
    edit: {
      editButtonContent: '<i class="nb-edit"></i>',
      saveButtonContent: '<i class="nb-checkmark"></i>',
      cancelButtonContent: '<i class="nb-close"></i>',
      confirmEdit: false,
    },
    delete: {
      deleteButtonContent: '<i class="nb-trash"></i>',
      confirmDelete: true,
    },
    actions: {
      add: true,
      edit: false,
      delete: false,
    },
    columns: {
      progress_date: {
        title: 'Date',
        type: 'date',
        filter: false
      },
      progress_percent: {
        title: 'Percentage Completed(%)',
        type: 'integer',
        filter: false,
      },
      note: {
        title: 'Note',
        type: 'string',
        filter: false
      },
    },
  };

1 个答案:

答案 0 :(得分:1)

如果您想刷新,此代码可能会帮助您

this.progressTableSource.refresh();

this.progressTableSource.empty();
this.progressTableSource.refresh();
this.progressTableSource.load(this.data);