I just figured out a way to fix the alignment issue. Changing the width of div containing the static header will fix its alignment. The optimal width I found is 98%. Please refer to the code.
The auto generated div:
Width here is 100%, change it to 98% on initializing and reloading the data table.
jQuery('#dashboard').dataTable({
"sEcho": "1",
"aaSorting": [[aasortvalue, 'desc']],
"bServerSide": true,
"sAjaxSource": "NF.do?method=loadData&Table=dashboardReport",
"bProcessing": true,
"sPaginationType": "full_numbers",
"sDom": "lrtip", // Add 'f' to add back in filtering
"bJQueryUI": false,
"sScrollX": "100%",
"sScrollY": "450px",
"iDisplayLength": '<%=recordCount%>',
"bScrollCollapse": true,
"bScrollAutoCss": true,
"fnInitComplete": function () {
jQuery('.dataTables_scrollHead').css('width', '98%'); //changing the width
},
"fnDrawCallback": function () {
jQuery('.dataTables_scrollHead').css('width', '98%');//changing the width
}
});