Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82284

How to stop the server side draw event when adding new data to table

$
0
0

I've table with data loaded from server side, as there will be huge datasets i've to go for server side loading.

This is my table config:

var table = $('#table').DataTable({ "processing": true, "serverSide": true, "ajax" : { "url": "...", "type": "POST" }, "columns": [ { "orderable": false, "data" : 'id', "render" : function( data, type, meta ) {

                return '..';
            }
        },
        {
            "orderable": true, 
            "data"     : ".."
        },
        {
            "orderable": true, 
            "data"     : "..",
            "className": 'right-align'
        },
        {
            "orderable": true,
            "data"     : "..",
            "className": 'right-align'
        },
        {
            "orderable": false,
            "data"     : 'id',
            "defaultContent": "",
            "className": 'center-align',
            "render"   : function(data, type, meta) {

                return '..';
            }
        },
        {
            "orderable": false, // flags
            "data"     : {
                'inserted' : 'inserted',
                'deleted'  : 'deleted'
            },
            "defaultContent": "",
            "className"    : 'center-align',
            "render"   : '..'
            }
        }
    ],
    'order': [
        [1, "asc"]
    ],
    "language": {
        "lengthMenu": '..'
    }
}); 

And I've to provide filtering capability for this table ( there are few checkboxes which will trigger the post request on change) so I'm send the filters to backend and it gives me new dataset.

$.post(url, { 'filters' : data} , function(collection){

 table.clear().draw();
 table.rows.add(JSON.parse(collection));
 table.columns.adjust().draw();

});

It's firing total 3 requests, one for the post request and two other the draw request ( As I'm drawing twice).

According to server side processing On every draw server side will fire the post request to update the table which is overriding the new dataset.

How can I draw the table with new dataset?

Please help me in resolving this issue.

Thanks a lot for making datatables.


Viewing all articles
Browse latest Browse all 82284

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>