customize sInfo message ?
customize sInfo message ?
nishant09
Posts: 2Questions: 1Answers: 0
Hi,
I'm new to datatable. Can I customize sInfo:""Showing START to END of TOTAL entries" string to something like below
sInfo: myFunction
myFunction() {
return "Showing n messages of queue myQueue"
}
I completely want to cutomize and use my own message/string
Can I do that ?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
If you have a look at the
language.info
documentation you'll see that it doesn't accept a function.However, you can use
infoCallback
to provide a function that has complete control over the information string.Allan
Thanks Allan. It helped to find the correct solution. I had to use footerCallback instead since the custom function had to call another function(back-end) and wait for the return value to customize and update the message.(Moreover,infoCallback accept string value only)
So in the footerCallback function, I update the html element to show my own info message.
{
"sInfo: " ",
"bInfo": true,
"footerCallback": getFooterInfo
}
function getFooterInfo {
$("#storageTable_info").html("Showing " + total + " messages of " + approximateMessageCount + " messages in queue");
}
However, I still have one small issue with this approach. When the table gets loaded it takes a few milliseconds to update the html element(call the back-end function and wait for the return value). In the meantime, I'm seeing the "Showing 5 to 5 of 5 entries" message in my info bar. which I want to hide/not display. That's a bad user experience.
Do you have input on this ?
Use the
language.info
option and set it to be an empty string. That should mean that you don't get the DataTables default message shown on initialisation.Regards,
Allan