This applies to datatables 1.10.x.
I use this link to create child lines, and it's easy to place HTML inside javascript code that is genereated, for example:
function format ( d ) { return '<div class="slider">'+ '<table id="expandInput" cellpadding="5" cellspacing="0" border="0" style="margin: 0 auto;">'+ '<tr>'+ '<td class="dropHeader">Cost</td>'+ '<td class="dropInfo"><input required type="text" id="cost" name="cost" value="'+d.cost+'"></input></td>'+ '</tr>'+ '</table>'+ '</div>'; }
But this only affects the child child that is generated by clicking the mouse. I have no idea how to create an id or name using the standard datatables syntax for cells that generate the data itself. The only example I could find on the datatables website is to create an id using the server side
var table = $('#ltc-table').DataTable( { "data" : json, "columns" : [ { data : 'cost' }, { data : 'resale' } ], "columnDefs": [ { className: "details-control", "targets": [ 0 ] } ] });
I know that I can set the td class using columnDefs , as shown here , but I cannot figure out how to add additional criteria, and I need to set unique id and name for each td that is genereated.
source share