Custom condition on a button

Custom condition on a button

pmatveevpmatveev Posts: 7Questions: 3Answers: 0

Hello Allan,

Could you please clarify if it is possible to set custom JS check whether button should be active or not?
Basically, I'd want to implement custom "jscheck" extension but I can't find a way to pass JS expression to a button on table initialization.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,059Questions: 26Answers: 4,903

    Is it possible for you to use the button().disable() and button().enable() APIs?

    Kevin

  • pmatveevpmatveev Posts: 7Questions: 3Answers: 0

    Hello Kevin,

    I believe my issue is slightly different. I can implement hardcoded conditions with this API (plus extensions) but what I really need is flexible solution when each button may have its own condition in JS.

    Here the issue is what's the correct way to pass and store JS expression for the button.

  • allanallan Posts: 62,945Questions: 1Answers: 10,356 Site admin
    Answer ✓

    The buttons.buttons.init function can be used for this.

    You can see how the Select library does that here. It uses an init function to add an event listener to whatever is needed in the table (item selection in that case) and then calls the API methods as needed.

    Allan

  • pmatveevpmatveev Posts: 7Questions: 3Answers: 0

    Hello Allan,

    Thank you, this helps a lot. I can use eval inside listeners to implement custom conditions.

This discussion has been closed.