Button Print cancel print on empty datatable?
Button Print cancel print on empty datatable?
jvcunha
Posts: 81Questions: 10Answers: 1
Hi,
it's possible cancel printing if empty datatable?
Thanks
This discussion has been closed.
Replies
Do you mean as the end user? If so, just press esc when the print dialogue shows up and you then decide you don't want to print it.
Allan
Sorry Allan, did not explain right.
When the datatable is empty, you should not print or export to Excel.
It is to disable buttons or intercepting the click and abort if it is empty?
Yes, what you could do is use the
draw
event in combination with thepage.info()
method to see if the table has any rows or not, then usebuttons().disable()
/buttons().enable()
to disable or enable the buttons as required.Allan
Thanks Allan, resolved in initComplete:
The only thing I would say about using
initComplete
is that it only runs once in the table's life cycle. If you were to use the API in any way to add new rows, then it wouldn't see the updates and enable the buttons again. Likewise, if there were records and then your user filtered them down to zero, that also wouldn't reflect in the buttons.The
draw
event I mentioned would address that.Allan