Custom condition on a button
Custom condition on a button
pmatveev
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
This discussion has been closed.
Answers
Is it possible for you to use the
button().disable()
andbutton().enable()
APIs?Kevin
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.
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
Hello Allan,
Thank you, this helps a lot. I can use eval inside listeners to implement custom conditions.