jeudi 20 octobre 2016

How to define an object property based on a if/else statement?

I'm trying to configure the state of a datatable button based on a if/else statement.

The datatable button object:

    buttons: [
        {
            text: "button text",
            action: function (e, dt, node, config) {
                button_action();
            },
            enabled: function () {
                if (column_exists) {
                    this.enabled = true
                } else {
                    this.enabled = false
                }
            }
      }
    ]

With this code, my button is always enabled. How can I set the enabled parameter correctly based on an if/else statement ?

Aucun commentaire:

Enregistrer un commentaire