如何重新初始化 jQuery datatable?我甚至尝试删除表格元素,但表格仍然显示。我的代码是这样的:
function removeExistingDataTableReference(tableid)
{
if(oTable !=null)
{
oTable.fnDestroy();
}
if(document.getElementById(tableid)){
document.getElementById(tableid).innerHTML="";
}
oTable=null;
try
{
if(oTable !=null)
{
//oTable.fnDestroy();
alert("error in fndestroy");
}
oTable=null;
if(document.getElementById(tableid)){
document.getElementById(tableid).innerHTML="";
}
if(document.getElementById("FTable"))
{
removeElement(document.getElementById("FTable"));
}
}
catch(e)
{
alert("Error happend:"+e.message);
}
}
function removeElement(element)
{
try
{
var elem = document.getElementById('FTable');
elem.parentNode.removeChild(elem);
//ert(element.parentNode.id);
//element.parentNode.removeChild(element);
alert("removed");
return true;
}
catch(e)
{
alert(e.message);
}
return false;
}
我该怎么做?点击搜索按钮后,表格被加载。当我使用另一个搜索参数进行搜索时,表格应该使用新数据重新加载。但并没有发生。如何解决?
表格是这样初始化的:
function createDataTable()
{
try
{
oTable = $('#FTable').dataTable( {
"bDestroy":true,
"bJQueryUI": true,
"sScrollX": "100%",
"sScrollXInner": tablewidth+"px",
"bScrollCollapse": true,
"bSort":false,
"iDisplayLength" : 50,
"sPaginationType" : "full_numbers",
"aLengthMenu": [[10, 18, 50, -1], [10, 18, 50, "All"]]
} );
new FixedColumns( oTable, {
"iLeftColumns": 1,
"iRightColumns": 1
} );
}
catch (e)
{
alert(e.message);
}
}