Filtering multiple columns problem when hiding columns
Filtering multiple columns problem when hiding columns
rfitzwater
Posts: 57Questions: 5Answers: 1
I have a table setup with inputs in each column footer so you can filter each column. This works when all columns are displayed. When I hide certain columns, the filtering gets screwed up. If I hide col. 2 then enter filter criteria in col 3 (which is now 2 since two is hidden), it is filtering the hidden column.
An example can be found here: http://comm.rider.edu/registrar/law_all.html
Try filtering on local cap column, and you will see it is actually filtering based on Enrolled column.
Any help is appreciated.
Thanks,
-Rhon
An example can be found here: http://comm.rider.edu/registrar/law_all.html
Try filtering on local cap column, and you will see it is actually filtering based on Enrolled column.
Any help is appreciated.
Thanks,
-Rhon
This discussion has been closed.
Replies
when you hide columns, apparently this correspondence between html column and datatables column is broken
what you should do is map the id of each footer input to a datatable column, not rely on the html table index.
NOTE: I have a global var set to oTable.
if no match is found, I return -1, so make sure your code detects NOT FOUND scenario
[code]
// get column number for a given column name. (check the datatable settings column name info)
// return -1 for not found
function get_column_number(name) {
name = name.toLowerCase(); // case insensitive match, cast all to lowercase
var aoColumns = oTable.fnSettings().aoColumns;
var numcols = aoColumns.length;
for (i=0; i
[code]
"aoColumns": [
{ "sName": "QAid", "sType" : 'qaid', "sWidth": 80 },
{ "sName": "QAid", "sTitle": "Action", "sWidth": 30, fnRender: make_delete_link, "bSortable": false, "bSearchable": false },
{ "sName": "Status", "sWidth": 60, "bSortable": false},
{ "sName": "DateReceived", "sWidth": 70, "sClass": "center", "sType": "string" },
{ "sName": "DateCompleted", "sWidth": 70, "sClass": "center", "sType": "string" },
{ "sName": "Author", "sWidth": 150 },
{ "sName": "Contract", "sWidth": 125 },
{ "sName": "Title", "sWidth": 100 },
{ "sName": "Description", "sWidth": 200 },
{ "sName": "Illustrator", "sWidth": 80 },
{ "sName": "notes", "sWidth": 140 },
{ "sName": "bText", "sWidth": 40, "bSortable": false },
{ "sName": "bPowerpoint", "sWidth": 40, "bSortable": false },
{ "sName": "bPoster", "sWidth": 45, "bSortable": false },
{ "sName": "bOverhead", "sWidth": 45, "bSortable": false },
{ "sName": "bSlide", "sWidth": 40, "bSortable": false },
{ "sName": "bMap", "sWidth": 40, "bSortable": false },
{ "sName": "bReprint", "sWidth": 45, "bSortable": false },
{ "sName": "other", "sWidth": 80 } ,
{ "sName": "pub_code", "sWidth": 150 },
{ "sName": "0 as relevance", "sTitle": "relevance", "sWidth": 30 }
],
[/code]
$("#" + this + ':input').live('keyup', function () {
Thanks!