1

Is it possible in jQuery dataTable to add loader when it has a custom language url? For example:

"language": 
  {          
    "processing": "<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>",
     "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
  }

When I have both it doesn't work, but if i comment url line, loader works.

3 Answers 3

1

I founded this article and I sent message to DataTable forum, and they sad:

This is something that is going to be added in for v2 of DataTables, which is in progress, but slowly.

Until then you would need to load the Ajax language information using $.getJSON (or similar) and then merge it into your local object as needed, then using the result in the DataTable configuration

UPDATE: I comment my source line and added text manually like this:

        "language": {
         // "sUrl": "../HTMLRepository/JsLocalization/DataTableLocalization_Serbian.json"
        "sEmptyTable": "Ni jedan podatak ne postoji za zadate kriterijume",
        "sInfo": "Prikaz _START_ do _END_ od ukupno _TOTAL_ redova po strani",
        "sInfoEmpty": "Prikaz 0 do 0 od ukupno 0 redova",
        "sInfoFiltered": "(filtrirano od ukupno _MAX_ redova)",
        "sInfoPostFix": "",
        "sInfoThousands": ",",
        "sLengthMenu": "Prikaz _MENU_ redova",
        "sLoadingRecords": "Molimo sačekajte, učitavanje u toku...",
        "sSearch": "Pretraži:",
        "sZeroRecords": "Podaci se ne podudaraju",
        "oPaginate": {
            "sFirst": "Prva",
            "sLast": "Poslednja",
            "sNext": "Sledeća",
            "sPrevious": "Predhodna"
        }          
    },

And in $(document).ready function i have

$('#patientsTable').on('processing.dt', function (e, settings, processing) {
    if (processing) {
        activateLoader();
        activateOverlay();
    }
    else {
         deactivateLoader();
         deactivateOverlay();
   }

And finally it works :) Thanks a lot @Shiladitya

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

Comments

0

Try;

"language": 
    {          
    "processing": "<span style='width:100%;'><img src='http://www.snacklocal.com/images/ajaxload.gif'></span>",
     "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
    }

Comments

0

Here you go with a solution using ES6 template literals

"language": 
  {          
    "processing": `<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>`,
    "url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
  }

Hope this will help you.

5 Comments

No errors. But if I comment line with url, loader works. I made some function like this, $('#patientsTable').on('processing.dt', function (e, settings, processing) { if (processing) { activateLoader(); activateOverlay(); } else { deactivateLoader(); deactivateOverlay(); } }).dataTable(); But it works just when i don't have custom language url... Any suggestion?
@Dacke I think it should be "language": { "sUrl": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" }
@Dacke Did you put the jQuery code inside $(document).ready(function(){});
No, because I have find() function which create this table.
@Dacke Wrap your code inside $(document).ready(function(){}).

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.