-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column filters #62
base: master
Are you sure you want to change the base?
Column filters #62
Conversation
@rvelseg thanks for submitting this! Could you give an example of how you'd use this feature? |
@rvelseg revisiting some older PRs on this repo. This looks interesting, but could you provide an example of how you'd use this feature? |
You would set that to true if you wanted to search a column vs everything on the screen its actually pretty useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes - I've sat on this PR for a long time. Sorry about that.
I think this feature is kind of neat, but we should make some changes before bringing it in.
'<input type="text" id="col_f-' + headerIdx + '" placeholder="filter column" />')); | ||
$tableHeadRow_filter[0].childNodes[headerIdx].childNodes[0].onchange = function(ee) { | ||
var i = parseInt(ee.target.id.substr(6)); | ||
CsvToHtmlTable_DataTable.column(i).search(this.value).draw(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this is a new vaiable to keep track of the DataTable
state. Is it necessary for this code to work? It seems a bit awkward to only use it for this feature. Maybe we should keep track of the DataTable
this way generally?
var $tableHeadRow_filter = $("<tr></tr>"); | ||
for (var headerIdx = 0; headerIdx < csvHeaderRow.length; headerIdx++) { | ||
$tableHeadRow_filter.append($("<th></th>").html( | ||
'<input type="text" id="col_f-' + headerIdx + '" placeholder="filter column" />')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option added to use filtering on singe columns.
It is mainly based in this code
https://datatables.net/extensions/fixedheader/examples/options/columnFiltering.html
I don't normally work in javascript, I did my best to make the code work, but I don't feel it is idiomatic. So, please change whatever you consider appropriate.