Read Language Element to generate selected rows number

Read Language Element to generate selected rows number

foxmedofoxmedo Posts: 19Questions: 3Answers: 0

Hello,

I need to read the language elements to use it in function below

var countSelectedRecords = function() {
        var selected = $('tbody > tr > td:nth-child(1) input[type="checkbox"]:checked', table).size();
**        var text = ?????.language.GroupActions;**
        if (selected > 0) {
            $('.table-group-actions > span', tableWrapper).text(text.replace("_TOTAL_", selected));
        } else {
            $('.table-group-actions > span', tableWrapper).text("");
        }
    };

the idea is when user click into the checkbox i will make the count to execute a group action this why i need to get the text message from the language file (the software are multilingue)

"language": { "url": "localhost/assets/datatables/i18n/" + user_lang_code + ".json" },

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @foxmedo ,

    The proper way to do this would be to use i18n() - you can give it a token like this:

    table.i18n('sLengthMenu')
    

    You can also get the full list of language options if you use the private data in settings()

    Cheers,

    Colin

  • foxmedofoxmedo Posts: 19Questions: 3Answers: 0
    edited August 2018

    hi @colin,

    i have already try this but im getting this error

    Uncaught TypeError: table.i18n is not a function

    i have check my datatables version using $.fn.dataTable.version i found 1.10.12

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,773
    Answer ✓

    Checkout this FAQ:
    https://datatables.net/faqs/index#api

    Kevin

  • foxmedofoxmedo Posts: 19Questions: 3Answers: 0

    i have solve the problem using

    var text = table.DataTable().i18n('selected.rows', {_: '%d',}, selected);
    

    thank you for your help

This discussion has been closed.