Error after using oTabble.rows().invalidate()

Error after using oTabble.rows().invalidate()

raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
edited April 2014 in DataTables 1.10
Hi Allan,

I am facing one issue making data invalidate.
With reference to the my requirement http://datatables.net/forums/discussion/19480%22#Item_9 ,
I made my columns serchable/non searchable dynamically.
But when my data is dom scourced and I make the column as searchable true or false and then Invalidating the data then, when we search,datatable throws error.

I am using below code
suppose I have 6 columns
[code]
(document).ready( function () {
var oTable=$('#example').dataTable({
"aoColumnDefs":[
{"bSearchable": false, "aTargets": [3] },
{"bVisible": false, "aTargets": [3] }
],

"iDisplayLength":-1

});

console.log("Data before invalidate "+oTable.fnGetData()); // here I Get All the data i.e. Array of 6 columns Array[6]

} );

function call(){
var oTable=$('#example').dataTable();
var table=$('#example').DataTable();
oTable.fnSettings().aoColumns[3].bSearchable=true;
table.rows().invalidate();
console.log(oTable.fnGetData()); //here I get only Array[5] i.e. one of the columns data is not considered
}
[/code]


And I am doing above all funcionality because :
We have some hidden columns in our appplication, and we need to apply filtering on those columns
1. Initially on load, I am making column as hidden and nonsearchable (So that, when we search using datatables default Filteing textbox, data from hidden column will not be considered).
2. On certain event (lets say onclick of the button) I want to filter the data, So I am making this hidden column searchable and invalidating the data (As shown in the call() method ) , and then applying the filter i.e. oTable.fnFilter()


Please refer example at http://live.datatables.net/eyixob/6/edit.

Click on the Invalidate Data button. this button triggers call() function and then makes 3rd column nonsearchable and invalidate its data.
Try to search on datatable..it throws warning saying explained in datatables.net/tn/4.

But in contrast when My data comes from server side (using sAjaxSource), then above warning does displayed and it works as expected. Its happening on dom source data only (I guess).
Is there any solutin for this ?

Thanks in Advance.

Replies

  • allanallan Posts: 61,438Questions: 1Answers: 10,049 Site admin
    > oTable.fnSettings().aoColumns[3].bSearchable=true;

    You can't do that. It is not a supported action. There is no public API to dynamically enable and disable a columns searchable flag, and changing it as you are will almost certainly result in an error somewhere (since, as I say, it is not supported).

    Allan
  • raul_lfcraul_lfc Posts: 21Questions: 1Answers: 0
    Thanks a lot Allan...
    Serverside loading the data...solved my issue !!
This discussion has been closed.