ghanemar / jquery-datatables-column-filter

Automatically exported from code.google.com/p/jquery-datatables-column-filter
0 stars 0 forks source link

Hidden columns cause filtering of wrong columns #125

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Hide a specific column
2. Enter value to filter
3. The column next to the one that's supposed to be filtered is filtered.

What is the expected output? What do you see instead?
Filtering of correct column.

What version of the product are you using? On what operating system?
Revision 73

Please provide any additional information below.
Attached is a copy of a demo html from your repository (called 
issue_hidden.html) and a patch for the js.

Original issue reported on code.google.com by alexande...@gmail.com on 21 May 2013 at 1:43

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
// deleted my previous comment because it wouldn't work for column index 0

Hello,

I just started using this library today, so I don't know if this is the best 
way to do it. I also don't actually know what bUseColVis does.  Anyway, I 
needed this done so I changed the _fnColumnIndex function and now you can 
specify "iFilterColumn" in aoColumns, and it works on hidden columns.  Only 
tested in Firefox on client side tables.

....
"aoColumns": [
 null,
 {'type': 'text'},
 null,
 {
 'type': 'select',
 'values': [
  {'value':'is_approved', 'label': 'Approved'},
  {'value':'not_approved', 'label': 'Not Approved'}
 ],
 'iFilterColumn': 2
},
...

function _fnColumnIndex(iColumnIndex) {
 if (properties.bUseColVis) {
  // this if is the new part
  if (typeof properties.aoColumns[iColumnIndex].iFilterColumn !== 'undefined'){
   return properties.aoColumns[iColumnIndex].iFilterColumn;
  }
  return iColumnIndex;
 } else {
  return oTable.fnSettings().oApi._fnVisibleToColumnIndex(oTable.fnSettings(), iColumnIndex);
 }
}

Criticism welcome.

Jared

Original comment by Jared.Be...@gmail.com on 10 Dec 2013 at 10:15