How do I remove the NEW button based on the record count
How do I remove the NEW button based on the record count
tonyhyams
Posts: 4Questions: 2Answers: 0
in TableTools
I want to limit a user to adding no more than 30 records. In order to do this I just wanted to not display the NEW record button if the number of records returned for them was > 30. Any ideas how to do this, I've tried various things and thought that using the page.info() might work but can't seem to get the syntax right
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
At the moment you would need to do something like this, using
drawCallback
ordraw
:The nasty bit is the selector for the TableTools button. You'll need to use the inspector in your browser to find the correct ID for your button. An upgrade is coming which will allow this behaviour through an IP.
Regards,
Allan
I've progressed a little, I've found the selector and can make it hide. However the condition table.page.info().recordsTotal >= 30 is returning a "Uncaught ReferenceError: table is not defined" error. I assume the table variable needs to be defined so page.info can be called. It is this syntax I can't get right. My code below. Thx for your help
Try this:
table
wasn't defined. You could have used it from theDataTable()
call, but the above is the way to be absolutely certain.Allan
Thanks this works fine. Thank for your help, saved me a load of time.