Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何从自定义渲染组件刷新ng2智能表_Angular_Ng2 Smart Table - Fatal编程技术网

Angular 如何从自定义渲染组件刷新ng2智能表

Angular 如何从自定义渲染组件刷新ng2智能表,angular,ng2-smart-table,Angular,Ng2 Smart Table,我已经创建了一个自定义渲染组件,用于将按钮添加到我的ng2智能表中。按钮显示正确,我可以执行操作。我现在想要的是在操作完成后刷新表 我怎样才能做到这一点?我已经在设置中添加了一个订阅服务器,并且正在从我的组件发出事件,但是从设置中,我如何调用另一个函数来执行源的刷新 代码如下: 设置: TableSettings = { columns: { documentId: { title: 'Document ID' }, button: { ti

我已经创建了一个自定义渲染组件,用于将按钮添加到我的ng2智能表中。按钮显示正确,我可以执行操作。我现在想要的是在操作完成后刷新表

我怎样才能做到这一点?我已经在设置中添加了一个订阅服务器,并且正在从我的组件发出事件,但是从设置中,我如何调用另一个函数来执行源的刷新

代码如下: 设置:

TableSettings = {
columns: {              
  documentId: {
    title: 'Document ID'
  },
 button: {
    title: 'Task Actions',
    type: 'custom',
    renderComponent: CustomButtonComponent,
    onComponentInitFunction :(instance: any) => {
      instance.retry.subscribe(row => {
       //TODO Refresh Table
    });}
  }
};
 export class CustomButtonComponent implements ViewCell, OnInit {
  renderValue: string;

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

  @Output() retry: EventEmitter<any> = new EventEmitter();

  constructor(){}

  onRetry() {   
    this.retry.emit(this.rowData);    
  }
}
自定义渲染组件:

TableSettings = {
columns: {              
  documentId: {
    title: 'Document ID'
  },
 button: {
    title: 'Task Actions',
    type: 'custom',
    renderComponent: CustomButtonComponent,
    onComponentInitFunction :(instance: any) => {
      instance.retry.subscribe(row => {
       //TODO Refresh Table
    });}
  }
};
 export class CustomButtonComponent implements ViewCell, OnInit {
  renderValue: string;

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

  @Output() retry: EventEmitter<any> = new EventEmitter();

  constructor(){}

  onRetry() {   
    this.retry.emit(this.rowData);    
  }
}
导出类CustomButtonComponent实现ViewCell,OnInit{
renderValue:字符串;
@Input()值:字符串|数字;
@Input()行数据:任意;
@Output()重试:EventEmitter=neweventemitter();
构造函数(){}
onRetry(){
this.retry.emit(this.rowData);
}
}

我已尝试编写此.source.refresh(),但出现无法访问未定义的属性源的错误。

我使用扩展运算符刷新ng2智能表数据:

this.config.results=[…this.config.results]

如果你把这一行放在你的代码中,你有//TODO标记,我想它会工作的。不确定,因为您没有提供演示:)

Zendev有一个很好的可读性的基本分解这个操作符的功能。我希望这有帮助