Strange Issue With Fixed Header

Strange Issue With Fixed Header

jamessteelforthjamessteelforth Posts: 17Questions: 4Answers: 0
edited July 2013 in General
Hi All, recently my boss asked me to implement the fixed header plug-in for datatables plug-in in salesforce. Now The way my code is designed is that every time search button is clicked i have a callback function to the db as well as an oncomplete function re-initializing the data tables.
Looking at the sample code for fixed headers i put the call to the function ' new FixedHeader( oTable );' inside the initialization block. Instaed of getting re-initialized every time, the header is getting created again and again. So with each call i have a new floating header plus the old one in some misplaced corner as well, how do i change this??
[code]
function Kudos()
{
oTable = $('.datatable').dataTable(
{
"iDisplayLength": 100,
"sDom": '<"H"T><"clear"><"H">t<"F"ip>',
"bRetrieve": true,
"aoColumnDefs": [ {
"aTargets": [3,4,5,6,7,8,9,10],
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
if ( sData < "0" ) {
$(nTd).css('color', 'red')
$(nTd).css('font-weight', 'bold')
}
}
} ],
"oTableTools":
{
"sSwfPath": "{!$Resource.SWF_File}",
"aButtons": [
{
"sExtends": "csv",
"sFileName": "PortFolio.csv",
"sButtonText":"Export"

}, "print" ]
},
"oColVis":
{
"activate": "mouseover"
},
"bAutoWidth": false,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 2, "asc" ]] ,
"bLengthChange": false,
"bFilter": true,
"aoColumns": [
{ "sWidth": "6%" },
{"sWidth": "6%"},
{"sWidth": "6%"},
{ "sWidth": "6%" },
{"sWidth": "6%"},
{"sWidth": "6%"},
{ "sWidth": "6%" },
{"sWidth": "6%"},
{"sWidth": "6%"},
{ "sWidth": "6%" },
{"sWidth": "6%"},
{"sWidth": "6%"},
{ "sWidth": "6%" },
{"sWidth": "6%"},
{"sWidth": "6%"}
]
});


new FixedHeader( oTable );

}
[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    FixedHeader doesn't actually have a destructor at the moment, which is a bit of a flaw... It would need to remove the DOM elements that it adds to the page and remove the events. This is something that needs to go into the next version of FixedHeader, so I don't have an immediate solution I'm sorry to say.

    I've opened a Github issue for this: https://github.com/DataTables/FixedHeader/issues/10

    Allan
This discussion has been closed.