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

Issue with fnInitComplete and AJAX source

$
0
0
Hi !

I'm trying to populate a table using an AJAX source, without server-side processing.

I think this is related to this post : http://datatables.net/forums/discussion/34/fninitcomplete-exists-or-just-a-myth/p1
But in my case, the DataTables params are externalized and not passed directly in the dataTable function.

Here is the code :

var oTable_myTableId;
var oTable_myTableId_params = {
   "bDeferRender":true,
   "sDom":"lfrtip",
   "fnInitComplete":function() { 
      oTable_myTableId.fnAdjustColumnSizing(true);
   },
   "aoColumns":[
      {
         "mData":"id",
      },
      {
         "mData":"firstName",
      },
      {
         "mData":"lastName",
      },
      {
         "mData":"address.town.name",
      },
      {
         "mData":"mail",
      }
   ]
};

$(document).ready(function(){
   $.ajax({ 
      url:'myUrl',
      dataType: 'json', 
      async: false, 
      success: function(data){
         oTable_myTableId_params.aaData = data;   
         oTable_myTableId = $('#myTableId').dataTable(oTable_myTableId_params);
      });
});

The error is :
Uncaught TypeError: Cannot call method 'fnAdjustColumnSizing' of undefined

When I remove the fnInitComplete parameter, it works well.

Any idea ?

Thanks !

Viewing all articles
Browse latest Browse all 83169

Trending Articles



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