I'm a newby so please bear with me. Here goes. I have some code that I inherited that uses JQuery and Datatables. Currently all columns seem to be aligned right by default. I would like to center align sponsor name, company and registration date, if possible. The issue is that all columns continue to right align when the table is rendered. Here is my code.
function sponsorInformation(sponsorData){
var h = '' + //
'<table id="sponsorTable">' + //
'<thead>' + //
'<tr>' + //
'<th>Sponsor Number</th>' + //
'<th>Sponsor Name</th>' + //
'<th>Sponsor Company</th>' + //
'<th>Sponsor Regitration Date</th>' + //
'</tr>' + //
'</thead>' + //
'</table>';
$('#sponsorInfoTableLocation').html(h);
var columns = [
{ data : 'sponsorNumber', sClass: 'right' },
{ data : 'sponsorName', sClass: 'left' },
{ data : 'sponsorCompany', sClass: 'left' },
{ data : 'sponsorRegistrationDate', sClass: 'left' }
];
var sponsorInfoTable = $('#sponsorTable').DataTable({
columns : columns,
data : sponsorData
});
}
The function passes in a JSON data object (sponsorData). The data itself is correct but I cannot get the alignments to work. I've looked for similar questions but none seem to address this scenario where the columns are defined as a variable and use columns.data. Any suggestions? What am I missing or doing wrong?
sClassattribute for your column which is a Legacy parameter. You just need to replacesClasswithclassName.