Hi Allan,
I'm a noob to DataTables and I am in total awe of the amazing quality of it all. Thanks for all the amazing hard work.
I want to create a table dynamically from data from a server.
Essentially I want to do this except with json from a server:
http://datatables.net/examples/data_sources/js_array.html
I've successfully used the following technique (works perfectly!!):
However, I just cannot get the following to work:
Both should be the exact same right?
I get the following error with the second version:
I've see a similar thread but I couldn't understand how it fully applies:
http://datatables.net/forums/discussion/3012/error-in-google-chrome/p1
Here is my json:
Kind regards,
Rory
I'm a noob to DataTables and I am in total awe of the amazing quality of it all. Thanks for all the amazing hard work.
I want to create a table dynamically from data from a server.
Essentially I want to do this except with json from a server:
http://datatables.net/examples/data_sources/js_array.html
I've successfully used the following technique (works perfectly!!):
var candidatesDataTable; $(document).ready(function() { $('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' ); $.getJSON( '/demos/candidateDataTables.json', null, function( json ) { candidatesDataTable = $('#example').dataTable( json ); }); });
However, I just cannot get the following to work:
var candidatesDataTable; $(document).ready(function() { $('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' ); candidatesDataTable = $('#example').dataTable({ "sAjaxSource": '/demos/candidateDataTables.json' }); });
Both should be the exact same right?
I get the following error with the second version:
Uncaught TypeError: Cannot read property 'asSorting' of undefined
I've see a similar thread but I couldn't understand how it fully applies:
http://datatables.net/forums/discussion/3012/error-in-google-chrome/p1
Here is my json:
{ "aaData": [ ["ANTRIM","19","32","49","156","17","159","0"], ["ARMAGH","2","10","4","19","2","8","0"], ["CARLOW","6","33","18","7","3","71","0"], ["CAVAN","10","67","20","7","6","59","0"], ["CLARE","17","56","47","7","16","104","0"], ["CORK","103","440","323","78","96","1115","0"], ["DERRY","5","14","11","47","5","34","0"], ["DONEGAL","23","103","44","38","20","154","0"], ["DOWN","21","91","34","40","14","122","0"], ["DUBLIN","543","1589","1478","272","485","6263","0"], ["FERMANAGH","0","5","0","6","0","1","0"], ["GALWAY","32","175","343","27","38","530","0"], ["KERRY","14","57","54","22","14","170","0"], ["KILDARE","31","146","73","22","24","339","0"], ["KILKENNY","10","56","27","7","13","128","0"], ["LAOIS","7","35","13","6","7","72","0"], ["LEITRIM","1","24","11","1","3","37","0"], ["LIMERICK","30","110","78","16","22","275","0"], ["LONGFORD","3","12","9","2","6","31","0"], ["LOUTH","5","31","18","11","6","66","0"], ["MAYO","28","68","49","9","14","120","0"], ["MEATH","17","75","58","20","16","231","0"], ["MONAGHAN","4","26","11","9","3","23","0"], ["OFFALY","5","22","17","5","2","54","0"], ["ROSCOMMON","5","21","13","4","3","44","0"], ["SLIGO","12","59","21","7","6","100","0"], ["TIPPERARY","14","74","46","15","15","161","0"], ["TYRONE","2","4","5","25","2","9","0"], ["WATERFORD","12","75","43","15","13","180","0"], ["WESTMEATH","3","18","13","2","2","33","0"], ["WEXFORD","13","49","42","18","13","172","0"], ["WICKLOW","15","54","47","10","11","194","0"], ["Ireland (County not specified)","226","892","646","197","162","2460","0"], ["Outside Ireland","30","59","75","22","14","295","0"], ["Unknown","630","1916","1936","932","571","7821","0"], ["Total","1898","6498","5676","2081","1644","21635","0"] ], "aoColumns": [ { "sTitle": "Region" }, { "sTitle": "Mary Davis" }, { "sTitle": "Seán Gallagher" }, { "sTitle": "Michael D. Higgins" }, { "sTitle": "Martin McGuinness" }, { "sTitle": "Gay Mitchell" }, { "sTitle": "David Norris" }, { "sTitle": "Dana Rosemary Scallon" } ] }
Kind regards,
Rory