Change language string in DataTables on draw() event

Change language string in DataTables on draw() event

awarnockawarnock Posts: 11Questions: 2Answers: 0

I'm using jQuery DataTables to display the results from a very slow database query. I have the table configured to display the empty table before the query is processed, and provided a checkbox to send off the search - when the checkbox is selected, I fire the DataTables().draw() function and it sends the AJAX request to the server. This all works the way I want.

What I'd like to do is change the emptyTable message when the checkbox is selected. Right now, before the checkbox is selected, it shows the emptyTable string (which I've set to "No records loaded"). When the checkbox is selected, I'd like to dynamically change the emptyTable string to something else (say, "Searching...").

I know it's still showing the emptyTable string because I've set the other language strings zeroRecords, loadingRecords and processing to different things just to make sure I see them. I've tried also calling the DataTables() object to update the language setting, but that gives an error message that I can't use that except at initialization.

Is there another way to accomplish this?

Thanks in advance.

Replies

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    It's not possible to do it with options or the API, but you could simply change it in the DOM like this,

    Colin

  • awarnockawarnock Posts: 11Questions: 2Answers: 0

    That helps. Thanks.

This discussion has been closed.