Display of custom button according to 'recordsTotal' in data
Display of custom button according to 'recordsTotal' in data
![Abdullah61](https://secure.gravatar.com/avatar/db6eb99f9408ea2fcefc901007800f63/?default=https%3A%2F%2Fvanillicon.com%2Fdb6eb99f9408ea2fcefc901007800f63_200.png&rating=g&size=120)
Sorry if this question has a solution already answered, I searched a lot but couldn't find it.
I am using server side.
In my example scenario I have a button and I want to control whether that button appears according to the 'recordsTotal' from the ajax response. I want to use buttons.available for this, but the DataTables API that this function takes is not working. Is there a solution to this?
This question has an accepted answers - jump to answer
Answers
Looks like the
buttons.buttons.available
runs before the asynchronous Ajax response has returned. That is why you seeundefined
in the console.Use
initComplete
for this. The second parameter isjson
which has the server side processing response. You can get therecordsTotal
value. You can use eitherbutton().add()
orbutton().remove()
to adjust the buttons based on therecordsTotal
value.Kevin
Thank you, a different perspective is always helpful.![:smile: :smile:](https://datatables.net/forums/resources/emoji/smile.png)