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

Failing to reload datatables with updated information

$
0
0
Hi Allan,

I'm working on a project in which I have to update the dataTable after I have performed some record update.
I'm using C# for the backend end I'm getting all json responses properly.

Here is how I go about it, please note that the following code is a minified version of the app I'm working on:
var oTable,
var otherVars; //global vars

var app = {
    getAllData: function() {
            return $.ajax({
                type: "POST",
                url: "/Services/SerialNumberLookupService.aspx/GetSerialWorkOrder",
                data: JSON.stringify(serverMethodParamObject),
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        },
    init: function(config) {
        var _self = this,
              deferred = $.Deferred();

        //some code...
        if (typeof oTable !== "undefined" && oTable !== null) {
            oTable.fnDestroy();
        }
        $.when(_self.getAllData()).done(function (resp) {
                    data = $.parseJSON(resp.d);

                    if ($('.dataTables_filter').length)
                        $('.dataTables_filter').remove();

                    oTable = $('table.dataContainer').dataTable({
                        aaData: data,
                        bFilter: true,
                        bInfo: false,
                        bPaginate: true,
                        sPaginationType: "full_numbers",
                        bJQueryUI: true 
                    });

         //some code...
         
         $("#save").on('click', function() {
             var _self = this;
             _self.init({/*config parm */}); // reloading the dataTable

             // more code below
         });
};

It reloads the data fine the first time, but the second time I get on the console: Uncaught TypeError: Cannot read property 'nTableWrapper' of null line 4557

Thank you for taking the time to response to this.

Viewing all articles
Browse latest Browse all 82257

Trending Articles



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