5

Im using Datatables with PHP and Mongo to make a CRUD.

This is my Code and it works fine

table = $('#example').DataTable({
    "bLengthChange": false,
    "ajax": "./get_clients"
});

This is my function to load new data and it works fine:

table.ajax.reload();

When I load the page I get a "Loading..." message, but when I reload with "table.ajax.reload()", I get no "Loading..." message which is annoying cause my users might not know the grid is loading.

I can add this line to my datatable params:

"processing": true,

And that would give me a "Processing..." Message with a different CSS style.

I'd like to know if there is a way to have the "Loading..." message with all of its properties while still using my reload ajax code.

Edit: Im' using version Data tables 1.10.10

1 Answer 1

9

Not really. The "Loading..." message is an actual table row that is added during initialisation, whereas the "Processing..." message is an overlay.

I suggest using the language feature to blank the "Loading..." message and just use the overlay:

$(document).ready( function () {
  var table = $('#example').DataTable( {
    ajax: '/ajax/arrays.txt',
    processing: true,
    'language':{ 
       "loadingRecords": " ",
       "processing": "Loading..."
    }
  } );

  $('#reload').click( function () {
    table.ajax.reload();
  } );

} );

You could of course not use   and set loadingRecords to an empty string, but that initial table row's height will collapse somewhat without.

Example: http://live.datatables.net/cepunoyi/1/edit

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.