Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Column filters #62

wants to merge 20 commits into from

Conversation

rvelseg
Copy link

@rvelseg rvelseg commented Jul 20, 2018

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.

@derekeder
Copy link
Owner

@rvelseg thanks for submitting this! Could you give an example of how you'd use this feature?

@derekeder
Copy link
Owner

@rvelseg revisiting some older PRs on this repo. This looks interesting, but could you provide an example of how you'd use this feature?

@CptPlastic
Copy link

You would set that to true if you wanted to search a column vs everything on the screen its actually pretty useful.

Copy link
Owner

@derekeder derekeder left a 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();
Copy link
Owner

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" />'));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code uses Bootstrap, so we should add the form-control and form-control-sm classes. Currently the default styles don't resize to fit the screen width and have a different aesthetic.
Screen Shot 2023-03-02 at 1 55 31 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants