如何获取 angular ng2-smart-table 过滤和排序外部事件?

How get angular ng2-smart-table filtering and sorting external events?

我有 REST API 后端,所以所有排序、过滤和分页都由后端管理。在我的 Angular 应用程序中,我想在 ng2 smart table 上显示数据。单击 table header 列名称(按升序、降序排序)后,table 内容仅在前端排序。我需要一些事件来调用 REST API 来更新数据(不仅是前端排序),同样我需要按 headers 输入字段进行过滤。输入过滤输入后,我需要调用 rest api 从后端获取过滤后的数据。

如果我将 table 模式设置为外部模式,我只会获得用于创建新项目、删除项目和编辑事件的事件。我怎样才能得到排序和过滤事件?

我尝试了智能 table 文档中的所有内容,但文档中的解决方案仅适用于创建删除和更新外部事件而不是排序和过滤

尝试将此代码添加到您的 ngOnInit()

this.tableData.onChanged().subscribe((change) => {

  if (change.action === 'filter') {        
    // Do whatever you want with the filter event

  }
});

注意: this.tableData 是您的 LocalDataSource。

Link for more details