Problem with simple "order": [[0, 'asc']]

Problem with simple "order": [[0, 'asc']]

elucasfreitaselucasfreitas Posts: 2Questions: 1Answers: 0
edited June 2020 in Free community support

Hi All,

I did start today work with datatables plugin in my personal project but the function "order" when load the page don't work, anyone know can be? (if I did click in asc or desc icon the "sort" funcioni is work fine..)
I will copy the code bellow (is copy from example..).

Thanks

my code:
My ideia is sorting the column "0" that the content is number of ID...

<script>
                $(document).ready(function(){
                    $('#minhaTabela').DataTable({
                        "language": {
                            "lengthMenu": "Mostrando _MENU_ registros por página",
                            "zeroRecords": "Nada encontrado",
                            "info": "Mostrando página _PAGE_ de _PAGES_",
                            "infoEmpty": "Nenhum registro disponível",
                            "infoFiltered": "(filtrado de _MAX_ registros no total)",
                            "order": [[0, 'asc']]
                        }
                    });
                });
  </script>

Edited by Kevin:  Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    Answer ✓

    Looks like you have "order": [[0, 'asc']] inside the language option. Move it outside like this:

                        $('#minhaTabela').DataTable({
                            "language": {
                                "lengthMenu": "Mostrando _MENU_ registros por página",
                                "zeroRecords": "Nada encontrado",
                                "info": "Mostrando página _PAGE_ de _PAGES_",
                                "infoEmpty": "Nenhum registro disponível",
                                "infoFiltered": "(filtrado de _MAX_ registros no total)",
                            },
                            "order": [[0, 'asc']]
                        });
    

    Kevin

  • elucasfreitaselucasfreitas Posts: 2Questions: 1Answers: 0

    Hi Kevin
    OMG!
    What was I thinking!
    Is true, You are right!

    perfect!
    Thanks Kevin

This discussion has been closed.