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

request an easy way to enable individual column searching #69

Closed
shewless opened this issue Apr 1, 2022 · 9 comments · Fixed by #81 or #82
Closed

request an easy way to enable individual column searching #69

shewless opened this issue Apr 1, 2022 · 9 comments · Fixed by #81 or #82

Comments

@shewless
Copy link

shewless commented Apr 1, 2022

datatables has support for individual column searching:
https://datatables.net/examples/api/multi_filter.html

I'm not sure if it's possible with itables currently to add the appropriate html and javascript to make this happen. It would be nice if it was an option (enable_column_search).

@mwouts
Copy link
Owner

mwouts commented Apr 1, 2022

Hi @shewless , thank you for the link, that is interesting!

Well I prefer to keep itables simple, and not add options that are not in datatables.net.

Still I'd be interested in seeing how we could translate the multi filter example to itables. I'm not sure we can do this at the moment (what is missing are 1. the footer cells and 2. the ability to run additional JS code), but I'll keep this in mind for later version. Is that something that would be of interest to you?

@shewless
Copy link
Author

shewless commented Apr 1, 2022

Thank you for the reply. If it's not simple to add it may not be worth it.

@mwouts
Copy link
Owner

mwouts commented Apr 1, 2022

I think allowing to do this kind of thing in itables is worth it... I've seen a few more cases for which we need additional JS code like here, so there is a point in doing so. I'll keep you updated (through this issue) when this becomes possible.

@shewless
Copy link
Author

shewless commented Apr 1, 2022

Thank you. I'll keep an eye on this issue.

@vttrifonov
Copy link

Just to add a bit weight in favor of doing this. In R DT the column filter feature is functional and very useful.

@mwouts
Copy link
Owner

mwouts commented Jun 23, 2022

Yes, I agree, generally speaking the DT package by RStudio is much more advanced than itables that is a simple wrapper.

I've looked at columnFilters and columnFilterRow in datatables.R and they are pretty long, I don't this I could maintain a code addition that long.

Nevertheless, I do like the example quoted by @shewless (https://datatables.net/examples/api/multi_filter.html), and that one seems much more accessible, especially in itables>=1.0.0 now that we don't use require any more and that the datatables_template_connected.html file is much simpler. The way I see a possible implementation is the following:

  • We add a new comment // pre-dt-code between line 28 and 29 that gets replaced with custom JS code if desired
    $(document).ready(function () {
    $('#table_id').DataTable(dt_args);
    });
  • And we update datatable_repr to generate specific "pre-dt-code" as well as the "initComplete" function from the DT example linked above.

Can you tell me how you would like to use this? I see that the R DT package uses a filter argument which takes values like

filter = list(
  position = 'top', clear = FALSE
)

@mwouts mwouts mentioned this issue Jun 23, 2022
5 tasks
@mwouts
Copy link
Owner

mwouts commented Jun 23, 2022

Indeed it looks like that we can do something. With the commit above I have been able to show column filters like this:
image

This involves much less code than in the R DT library, but I'm starting to understand why... The search box will only work as a text search, while the R DT column search box let the user search by range or values. Hopefully you're not going to ask me such advanced search boxes 😄
image

mwouts added a commit that referenced this issue Jun 23, 2022
- `itables.options` and the `show` function have a new `column_filters` argument to display individual column search boxes ([#69](mwouts/jupytext#69))
- We have documented DataTables' `dom` option.
- We have introduced a new class `JavascriptFunction` to limit the evaluation of Javascript function to selected ones.
- The documentation is formatted with `black` thanks to a Jupytext & Black pre-commit hook.
@mwouts
Copy link
Owner

mwouts commented Jun 23, 2022

The new option column_filters is available in itables==1.1.0 and the updated documentation should soon appear at https://mwouts.github.io/itables/advanced_parameters.html

@mwouts
Copy link
Owner

mwouts commented Jun 23, 2022

Oh sorry some files did not make it to the pip package... This should be fixed with #82 in itables==1.1.1.

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 a pull request may close this issue.

3 participants