Как передать значения в функцию (e, dt, node, config) для dtOptions.buttons? - PullRequest
0 голосов

Я хочу передать значения в функцию (e, dt, node, config) для dtOptions.buttons

угловой 6

Как передать значения в функцию (e, dt, node, config) для dtOptions.buttons?

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-buttons-extension',
  templateUrl: 'buttons-extension.component.html'
})
export class ButtonsExtensionComponent implements OnInit {
  // Must be declared as "any", not as "DataTables.Settings"
  dtOptions: any = {};
  val=10;

  ngOnInit(): void {
    this.dtOptions = {
      ajax: 'data/data.json',
      columns: [{
        title: 'ID',
        data: 'id'
      }, {
        title: 'First name',
        data: 'firstName'
      }, {
        title: 'Last name',
        data: 'lastName'
      }],
      // Declare the use of the extension in the dom parameter
      dom: 'Bfrtip',
      // Configure the buttons
      buttons: [
        'columnsToggle',
        'colvis',
        'copy',
        'print',
        'excel',
        {
          text: 'Some button',
          key: '1',
          action: function (e, dt, node, config) {
            alert(this.val);
          }
        }
      ]
    };
  }
}

console.log: не определен

1 Ответ

0 голосов
/ 12 мая 2019

Вы можете попробовать что-то вроде этого:

{
  text: 'Some button',
  key: '1',
  action: (e, dt, node, config) => this.methodName(e, dt, node, config) {
  alert(this.val);
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...