Table is loaded but sort and search doesn't work ( AJAX )

Table is loaded but sort and search doesn't work ( AJAX )

alberto2442alberto2442 Posts: 2Questions: 1Answers: 0

Hello,

I succeed to load data from php script but when I try to sort the table or to search a value, I see AJAX been executed.I think that's the problem.

Should I use initcomplete instead ?

        jQuery(document).ready(function() {
            var table = $('#table_list_user').DataTable( {
                "dom": '<"toolbar">frtip',
                "bDestroy": true,
                "serverSide": true,
                "bSortable":true,
                "bSearchable":true,
                "ajax":{
                    "url": '/mysql/function_users.php',
                    "type": 'POST',
                    "data": function ( d ) {
                        d.myKey = "list_users";
                    },
                },
                "columns": [
                    {
                        "class":          'details-control',
                        "orderable":      false,
                        "data":           null,
                        "defaultContent": ''
                    },
                    { "data": "name", "title": "name"},
                    { "data": "surname", "title": "surname"},
                    { "data": "email", "title": "email"},
                    { "data": "region", "title": "region"},
                    { "data": "last_modification", "title": "last modification" }
                ],
                "order": [[1, 'asc']]
            });
        });

Thank you by advance.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Did you read the docs on server-side processing?
    http://datatables.net/examples/data_sources/server_side.html

    Sorting and searching become the responsibiity of your own server-side script.

  • alberto2442alberto2442 Posts: 2Questions: 1Answers: 0

    I checked it already. Do you mean that if I'm not using the "server-side processing" scripts provided in the example I can not sort and search ?

    Currently I returning a table which look like this as describe in the "server-side" documentation :

    {"draw":1,"recordsTotal":5,"recordsFiltered":5,"data":[{"name":"toto","surname":"toto","email":"toto@toto.com","region":"latam","last_modification":"Mon Sep 8 2:15:37 UTC 2014"},{"name":"tata","surname":"tata","email":"tata@tata.com","region":"emea","last_modification":"Mon Sep 8 2:15:37 UTC 2014"},{"name":"titi","surname":"titi","email":"titi@titi.com","region":"asia","last_modification":"Mon Sep 8 2:15:37 UTC 2014"},{"name":"tutu","surname":"tutu","email":"tutu@tuttu.com","region":"latam","last_modification":"Mon Sep 8 2:15:37 UTC 2014"},{"name":"tsdfiti","surname":"titi","email":"tisdsfti@titi.com","region":"asia","last_modification":"Thu Jan 1 0:00:00 UTC 1970"}]}

    can you be more specific please ?

This discussion has been closed.