fnClearTable not removing data
fnClearTable not removing data
qbik
Posts: 2Questions: 0Answers: 0
Hi,
I've been using datatables for a new project and all works well, except when I want to reset the table when receiving an empty filter, here is my code:
[code]
function initTable ()
{
return $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bSort": false,
"sDom": 'tr',
"bRetrieve": true,
"sAjaxSource": "pro.php",
"iDeferLoading": 0,
"bInfo": false,
"bSortClasses": false,
"bDeferRender": true,
"oSearch": {"bCaseInsensitive": false},
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 1, 2 ] }
],
"oLanguage": {
"sSearch": "Search Country:",
"sZeroRecords": "No records to display",
"sEmptyTable": "No data available in table"
}
} );
}
function tableActions ()
{
var oTable = initTable();
$("#btnSubmit").click(function(){
string_to_search = $('#lop').val();
if(string_to_search != '')
{
//alert(string_to_search);
oTable.fnFilter(string_to_search);
}
});
$("#reset").click(function(){
oTable.fnClearTable();
});
}
$(document).ready(function(){
initTable();
tableActions();
});
[/code]
When clicking on the reset button all data still there.
Thanks for your help
I've been using datatables for a new project and all works well, except when I want to reset the table when receiving an empty filter, here is my code:
[code]
function initTable ()
{
return $('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bPaginate": false,
"bLengthChange": false,
"bSort": false,
"sDom": 'tr',
"bRetrieve": true,
"sAjaxSource": "pro.php",
"iDeferLoading": 0,
"bInfo": false,
"bSortClasses": false,
"bDeferRender": true,
"oSearch": {"bCaseInsensitive": false},
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 1, 2 ] }
],
"oLanguage": {
"sSearch": "Search Country:",
"sZeroRecords": "No records to display",
"sEmptyTable": "No data available in table"
}
} );
}
function tableActions ()
{
var oTable = initTable();
$("#btnSubmit").click(function(){
string_to_search = $('#lop').val();
if(string_to_search != '')
{
//alert(string_to_search);
oTable.fnFilter(string_to_search);
}
});
$("#reset").click(function(){
oTable.fnClearTable();
});
}
$(document).ready(function(){
initTable();
tableActions();
});
[/code]
When clicking on the reset button all data still there.
Thanks for your help
This discussion has been closed.