Why not let the aoColumns -array function be dynamically generated?
Using this approach, the data will be initialized correctly, regardless of whether the table has 1, 3, or 1000 columns.
If you want to estimate the width of the columns based on the column heading and not their indexes, you will need to change the aoColumn function to litte bit:
function aoColumns() { var ao = []; $("#table th").each(function(i, th) { var caption=$(th).text(); switch (caption) { case 'A' : ao.push({"sWidth": "50px"}); break; case 'B' : ao.push({"sWidth": "100px"}); break; default : ao.push({"sWidth": "25px"}); break; } }); return ao; }
source share