mwouts / itables

Pandas DataFrames as Interactive DataTables
https://mwouts.github.io/itables/
MIT License
740 stars 55 forks source link

request an easy way to enable individual column searching #69

Closed shewless closed 2 years ago

shewless commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

mwouts commented 2 years ago

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 commented 2 years ago

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

vttrifonov commented 2 years ago

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

mwouts commented 2 years ago

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:

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 commented 2 years ago

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 :smile: image

mwouts commented 2 years ago

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 commented 2 years ago

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