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

SearchBuilder & Checkboxes #284

Open
on46zohu opened this issue Jun 5, 2024 · 4 comments · Fixed by #286
Open

SearchBuilder & Checkboxes #284

on46zohu opened this issue Jun 5, 2024 · 4 comments · Fixed by #286

Comments

@on46zohu
Copy link

on46zohu commented Jun 5, 2024

Due to a need of higher interactivity, I've integrated a simple checkbox mechanism to the show() function so that the user can show/hide the columns preferred (as below).

But the thing is, each time I add a condition using the "Custom Search Builder", and then select/deselect a checkbox, the search builder resets, and the filters I set disappears.

Of course, I do not expect you to improve/fix my code, but wanted to ask if you could suggest anything to better handle this issue. In addition, do you have any plan to implement any similar built-in extension in itables in the near future? Thanks!

image

@mwouts
Copy link
Owner

mwouts commented Jun 5, 2024

Oh nice, thanks for sharing! Well I see that datatables has a column visibility button - I've not tried it yet but maybe you could use that, and hopefully the integration with the search builder would work better?

@on46zohu
Copy link
Author

on46zohu commented Jun 6, 2024

Thanks for the link! Maybe a dummy question, but I haven't used any extension directly from DataTables.
How to, for example, add the column visibility button extension (which is no Python code) to the show() call below?
show(df,
layout={"top1": "searchBuilder"},
)

@mwouts
Copy link
Owner

mwouts commented Jun 8, 2024

Hi @on46zohu , sure I've had to add the column visibility button in the package. It's available in itables==2.1.1 and documented here, let me know how it works for you.

@on46zohu
Copy link
Author

on46zohu commented Jun 10, 2024

Hi @mwouts. It works great, thanks a lot for the quick addition!
Just one note:
The below show() call works just fine, but if you add the following parameters, the search builder becomes unresponsive: column_filters=False, searching=False

My intention was to remove the search option, which I never use: https://mwouts.github.io/itables/advanced_parameters.html#search

But instead, I added pageLength to the layout, where normally the search option is located.

Hope it helps somehow!

show(
    df,
    column_filters=False,
    searching=False,
    columnDefs=[
        {
            "targets": [0,1,2],
            "visible": True,
        },
        {"targets": "_all", "visible": False},
    ],
    buttons=[
        {
            "extend": "colvis",
            "collectionLayout": "fixed columns",
            "postfixButtons": ["colvisRestore"],
        },
    ],
    layout={
        "top1": "searchBuilder",
        "topEnd": "pageLength",
    },
    language={
        "buttons": {"colvis": "Columns"},
    },
)

@mwouts mwouts reopened this Jun 11, 2024
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.

2 participants