dynamic column toggling example conflicts with individual column filtering example
dynamic column toggling example conflicts with individual column filtering example
I want the user to be able to dynamically show/hide columns. I have this working with this example;
http://datatables.net/beta/1.7/examples/api/show_hide.html
The user wants per-column based filtering and I have it working with this example;
http://datatables.net/examples/api/multi_filter.html
The problem is, if you combine them, when you remove a column, the filter order is still the same. For example. Let's say you have 10 columns and remove column 2. The filtering for column 10 is removed and if you type in the column filter box for column 2 (which WAS column 3), it still filters as if it's column 2. It's easy to test. Just take the per-column based filtering example and add a toggle button for any column an onclick('fnShowHide(2)'). 2 here is whatever column you want to show and hide.
ie:
Column
Just add the javascript function from the example;
function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#example').dataTable();
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
Help!
http://datatables.net/beta/1.7/examples/api/show_hide.html
The user wants per-column based filtering and I have it working with this example;
http://datatables.net/examples/api/multi_filter.html
The problem is, if you combine them, when you remove a column, the filter order is still the same. For example. Let's say you have 10 columns and remove column 2. The filtering for column 10 is removed and if you type in the column filter box for column 2 (which WAS column 3), it still filters as if it's column 2. It's easy to test. Just take the per-column based filtering example and add a toggle button for any column an onclick('fnShowHide(2)'). 2 here is whatever column you want to show and hide.
ie:
Column
Just add the javascript function from the example;
function fnShowHide( iCol )
{
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#example').dataTable();
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
Help!
This discussion has been closed.
Replies
Allan
And then;
$.fn.dataTableExt.oApi.fnVisibleToColumnIndex = function ( oSettings, iMatch )
{
return oSettings.oApi._fnVisibleToColumnIndex( oSettings, iMatch );
};
But it's still filtering on the original columns and it didn't remove the filter box for the removed column.
Allan