DataTables警告:表ID = DataTables_Table_0-无法重新初始化DataTable

时间:2019-03-29 15:35:15

标签: javascript angular datatable datatables angular6

我正在根据从dropDown中选择的值来更改表。 当我通过dropDown更改值时,出现“无法重新初始化DataTable错误”。

getResults(input) {
    this.suiteResults = [];
    this.suitService.getAllSuite(clientID).subscribe(r => {
      this.suiteResults = <any[]>r;
      // Calling the DT trigger to manually render the table
      this.dtTrigger.next();
      console.log("getAllSuite response r is :" + JSON.stringify(this.suiteResults));
    });
  }
  
  ............
  ngOnDestroy(): void {
    // Do not forget to unsubscribe the event
    this.dtTrigger.unsubscribe();
  }
  ngOnInit() {
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 10
    };

    this.dtTrigger.next();

  }
 <select   name="selectedClient"  [(ngModel)]="selectedClient"  (change)="getResults(selectedClient)">
       
      <option *ngFor="let client of clientList" [ngValue]="client">{{client}}</option>
    </select>  


  </div>
</div>



<div class="row-fluid" id="rowPadding">
  <div class="col-12 colBorder">
    <table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" class="table table-striped" >
      <thead>
        <tr>
          <th *ngFor="let heading of headers">{{heading}}</th>
        </tr>.....................................................................................................
this.dtTrigger.next()在getResults和ngOnInit中被调用...我应该怎么做,以便当dropDown更改时,我不会收到重新初始化错误

0 个答案:

没有答案