Sorting language with intl.js

Sorting language with intl.js

irelevantirelevant Posts: 15Questions: 4Answers: 1
edited June 2018 in Free community support

Hello,

i looking for change local for sorting in tables. I found that best idea is intl.js. But its not working for me. Inspect show this error:
TypeError: Cannot read property 'ext' of undefined
at intl.js:72
$.fn.dataTable.ext.order.intl = function ( locales, options ) {
at intl.js:66
factory( jQuery, window, document );
at intl.js:69
(function( $, window, document ) {

I dont know what going on because its javascript from original page. Here is my code definition for order and table:

        $.fn.dataTable.ext.order.intl('fr');
        var table = $('#myTable').DataTable({
            columnDefs: [
                { orderable: true, targets: 0 },
                { orderable: true, targets: 1 },
                { orderable: true, targets: 2 },
                { orderable: false, targets: 3 },
                { orderable: false, targets: 4 }
            ],
            oLanguage: {
                oAria: {
                    "sSortAscending": "Usporiadať vzostupne",
                    "sSortDescending": "Usporiadať zostupne"
                },
                oPaginate: {
                    "sFirst": "Prvá strana",
                    "sLast": "Posledná strana",
                    "sNext": ">",
                    "sPrevious": "<"
                },
                sEmptyTable: "Žiadne zaznamenané kontakty",
                sInfo: "Zobrazené od _START_ po _END_ z celkového počtu _TOTAL_",
                sInfoEmpty: "Žiadne zaznamenané kontakty",
                sInfoFiltered: "(vyfiltrované z _MAX_ všetkých kontaktov)",
                sLengthMenu: "Zobraziť _MENU_ kontaktov na stranu",
                sLoadingRecords: "Prosím počkajte - načítavam...",
                sProcessing: "Spracúvam údaje",
                sSearch: "Vyhľadať:",
                sZeroRecords: "Žiadne zaznamenané kontakty",
            },
            dom: "<'row'<'col-sm-4'l><'col-sm-4 toolbar'><'col-sm-4'f>>" +
                "<'row'<'col-sm-12'tr>>" +
                "<'row'<'col-sm-5'i><'col-sm-7'p>>",
            aLengthMenu: [
                [10, 25, 50, 100, -1],
                [10, 25, 50, 100, "Všetky"]
            ],
            "paging": false,
            "ordering": true,
            "info": true,
            "stateSave": false,
            "searching": true
        });

Thank you for any advice.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,174Questions: 1Answers: 2,589

    Hi @irelevant ,

    The only ext on that code comes from $.fn.dataTable.ext.order.intl. Have you included the jQuery and DataTable sources before you make that call?

    Cheers,

    Colin

  • irelevantirelevant Posts: 15Questions: 4Answers: 1

    Hi @colin thank you for your response. Here is my script include:
    JS Global Compulsory
    <script src="~/assets/vendor/jquery/jquery.js"></script>
    <script src="~/assets/vendor/jquery-migrate/jquery-migrate.min.js"></script>
    <script src="~/assets/vendor/jquery.easing/js/jquery.easing.js"></script>
    <script src="~/assets/vendor/popper.min.js"></script>
    <script src="~/assets/vendor/bootstrap/bootstrap.js"></script>
    dataTables
    <script src="~/js/intl.js"></script>
    <script src="~/js/datatables.js"></script>

    And one more error showing in inspect but i thought is not important and its just because of error of intl.js or something else but maybe its more important than i think:

    $.fn.dataTable.ext.order.intl is not a function
        at HTMLDocument.<anonymous> (Index:396)
        at HTMLDocument.dispatch (jquery.js:4732)
        at HTMLDocument.elemData.handle (jquery.js:4544)
        at Object.trigger (jquery.js:7788)
        at Object.a.event.trigger (jquery-migrate.min.js:2)
        at a.fn.init.triggerHandler (jquery.js:7878)
        at Function.ready (jquery.js:3535)
        at HTMLDocument.completed (jquery.js:3547)
    
  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    Swap your datatables.js and intl.js files around. intl.js contains a plug-in for DataTables.

    Allan

  • irelevantirelevant Posts: 15Questions: 4Answers: 1
    edited June 2018

    @allan its working. Thank you.

This discussion has been closed.