Sorting (alphabetical order) to ignore empty cells : dataTables

后端 未结 2 403
栀梦
栀梦 2020-12-30 13:47

So the question has already been asked here, but the solution doesn\'t work for me (I might do something wrong). I want to sort my tables by alphabetical order (\"type\" : \

2条回答
  •  醉话见心
    2020-12-30 14:25

    Ok I found a solution for my second problem , see Here

    So destroy the dataTable just before my ajax request and rebuild it on success :

        else{
            // Destroy dataTable
            $('#classement').dataTable().fnDestroy();
            $.ajax({
                type: "POST",
                url: "ajax.php",
                data: {},
                success: function(msg){
                    // Reload dataTable with sorting
                    $('#classement').dataTable({
                        columnDefs: [
                           {type: 'non-empty-string', targets: [2,3]} // define 'name' column as non-empty-string type
                        ]
                    });
                }
            });
        }
    

    Example : JsFiddle

提交回复
热议问题