Problems deleting rows and the table's style (fnClearTable function)

Problems deleting rows and the table's style (fnClearTable function)

merlinpjmerlinpj Posts: 4Questions: 0Answers: 0
edited April 2014 in DataTables 1.9
I want to search in my database and show the results in a datatable. But i have some problems. After the first search, I have to delete the previous rows to show the new results. To remove all rows I am using fnClearTable() but
- it changes the style of the table.
- the footer of the table always shows the quantity is 0 when it is not. It lists the expected result.
- because the "quantity is 0", the previous and next buttons are disabled, it is not possible to sort by columns neither use the search filter.
- the internalization does not work.

If I comment the line $('#displayData').dataTable().fnClearTable(); all these problems disappear but the new rows of the search are added to the current table's data source.

There are my html / javascript codes respectively:
[code]
$.ajax({ // search button click
url: '../xxx/search.php',
type: 'POST',
data: 'idxxx=1',
dataType: 'json',
success: function(response) {
var thtml = "";
$('#displayData').dataTable().fnClearTable();
if(response.length > 0) {
$.each(response, function(index, record) {
thtml += "";
thtml += "" + record.Name + "" ;
thtml += "" + record.BDay + "";
thtml += "" + record.Code + "";
thtml += "";
});
}
$('#displayData tbody').append(thtml);
$('#resultContainer').css({"visibility":"visible"});
$('#displayData').dataTable({
"bRetrieve": true,
"oLanguage": {
"sUrl": "../xxx/DataTables-1.9.4/pt.txt"
},
"sPaginationType" : "full_numbers"
});
}
});
[/code]

[code]



Name
Birthday
Code





[/code]

Thanks in advance!

Replies

  • merlinpjmerlinpj Posts: 4Questions: 0Answers: 0
    edited April 2014
    I can substitute $('#displayData').dataTable().fnClearTable() for $('#displayData tbody').empty() or $('#displayData tbody').html('') , but the footer of the table does not update the quantity of items and the style of the table still does not work.
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin
    Can you link to a test case please?

    Allan
  • merlinpjmerlinpj Posts: 4Questions: 0Answers: 0
    edited May 2014

    Hi Allan,

    I already resolved that problem using sAjaxSource and fnServerData in the version 1.10.
    Thanks anyway.

    Continue working hard in Datatables. it is awesome.

This discussion has been closed.