javascriptlaravellaravel-datatables

I failed to refresh data in yajra/laravel-datatables-oracle with draw method


In laravel 6 app I use "yajra/laravel-datatables-oracle": "^9.4" and I need selecting 1 row and running ajax request on server to delete this row I try to refresh table with draw() method and it does not work.

In my blade file :

@push('scripts')

    var oTable;
    $(document).ready(function () {

            oTable = $('#my_tasks_data').DataTable({
                processing: true,
                serverSide: false,
                info: false,
                order: [],
            });
            $('div.dataTables_length select').select2({
                theme: "bootstrap"
            });

            ...
        function taskComplete(rowId) {
            $.ajax({
                url: 'tasks/' + rowId + '/complete',
                type: "post",
                dataType: 'json',
                data: {'_token': '{{csrf_token()}}'},
                success: function (data) {
                    console.log('taskComplete success data::')
                    console.log(data)
                    console.log('oTable::')
                    console.log(oTable)   
                    oTable.draw();  // THat does not work

                    alert( 'AFTER::' )
                },
                error: function (xhr) {
                    console.error(xhr)
                }
            });

        }

I check oTable var and see : https://prnt.sc/ujyp14 It looks like valid Table object

Why it does not work and how it can be fixed?

Thanks!


Solution

  • I found decision with setting serverSide property to true

    oTable = $('#my_tasks_data').DataTable({
        processing: true,
        serverSide: true,
    

    and after that method oTable.draw() works ok