Angulardatatable的重新渲染在表格中生成重复项,重复项在页面刷新后消失。
创始人
2024-10-24 00:32:08
0

可以在调用rerender方法之前清空表格数据。以下是一个示例代码:

import { Component, OnInit, ViewChild } from '@angular/core';
import { DataTableDirective } from 'angular-datatables';
import { Subject } from 'rxjs';

@Component({
  selector: 'app-table',
  templateUrl: './table.component.html',
  styleUrls: ['./table.component.css']
})
export class TableComponent implements OnInit {
  
  @ViewChild(DataTableDirective) datatableElement: DataTableDirective;
  dtOptions: DataTables.Settings = {};
  dtTrigger: Subject = new Subject();

  constructor() { }

  ngOnInit() {
    this.dtOptions = {
      // DataTables options
    };
  }

  rerender() {
    // 清空表格内数据
    this.dtTrigger.next();
    this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => {
      dtInstance.destroy();
      this.dtTrigger.next();
    });
  }
}

相关内容

热门资讯

普及透视!xpoker辅助神器... 普及透视!xpoker辅助神器!其实是真的有辅助插件(有挂技巧)-哔哩哔哩该软件可以轻松地帮助玩家将...
普及透视!poker worl... 普及透视!poker world辅助!一直真的有辅助脚本(竟然有挂)-哔哩哔哩暗藏猫腻,小编详细说明...
详细透视!佛手在线大菠萝为什么... 详细透视!佛手在线大菠萝为什么都输!切实存在有辅助工具(了解有挂)-哔哩哔哩1、点击下载安装,佛手在...
普及透视!pokerrrr2辅... 普及透视!pokerrrr2辅助!真是真的是有辅助教程(存在有挂)-哔哩哔哩1、用户打开应用后不用登...
揭幕透视!哈糖大菠萝攻略!好像... 揭幕透视!哈糖大菠萝攻略!好像真的有辅助插件(有挂教程)-哔哩哔哩1、哈糖大菠萝攻略辅助软件下载优化...
分享透视!xpoker辅助器!... 分享透视!xpoker辅助器!其实一直总是有辅助方法(发现有挂)-哔哩哔哩运xpoker辅助器辅助工...
开挂透视!pokemmo手机辅... 开挂透视!pokemmo手机辅助软件!都是有辅助脚本(真是有挂)-哔哩哔哩1、pokemmo手机辅助...
详情透视!xpoker透视辅助... 详情透视!xpoker透视辅助!真是真的有辅助神器(真是有挂)-哔哩哔哩1)xpoker透视辅助免费...
解谜透视!哈糖大菠萝攻略!好像... 解谜透视!哈糖大菠萝攻略!好像存在有辅助工具(真是有挂)-哔哩哔哩1、任何哈糖大菠萝攻略透视是真的假...
揭幕透视!约局吧游戏挂!总是是... 揭幕透视!约局吧游戏挂!总是是真的有辅助app(今日头条)-哔哩哔哩1、上手简单,内置详细流程视频教...