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 Requires DateTime when used with dates. #288

Closed
pali07 opened this issue Jun 10, 2024 · 8 comments · Fixed by #289
Closed

SearchBuilder Requires DateTime when used with dates. #288

pali07 opened this issue Jun 10, 2024 · 8 comments · Fixed by #289

Comments

@pali07
Copy link

pali07 commented Jun 10, 2024

image

Can anyone please help me with this issue. unable to install the datetime library

@mwouts
Copy link
Owner

mwouts commented Jun 10, 2024

Hi @pali07 , thanks for reporting this.

Could you show us the error message, and copy your example as text too? Thanks!

@pali07
Copy link
Author

pali07 commented Jun 10, 2024

Not getting any error message getting table but search builder is not working
image

After clicking on searchbuilder button the output is as follows

image

@pali07
Copy link
Author

pali07 commented Jun 10, 2024

import pandas as pd
from itables import init_notebook_mode, show
from datetime import date, datetime

init_notebook_mode(all_interactive=True)

def convert_to_table(data, description=None, column_names=None, specified_columns=None):

    df = pd.DataFrame(data, columns=column_names)
    if column_names is None and df.columns.nlevels == 1:
        column_names = df.columns.tolist()
    if column_names:
        column_names = [col.strip('_').capitalize() for col in column_names]
        df.columns = column_names

    if specified_columns:
        df = df[specified_columns]

    show(
        df,
        classes="display nowrap cell-border top-border",
        scrollX=True,
        dom="Bfrtip",
        buttons=[
            "colvis",
            "pageLength",
            {
                "extend": "collection",
                "text": "Export",
                "buttons": [
                    {"extend": "csvHtml5", "title": "data"},
                    {"extend": "excelHtml5", "title": "data"}
                ]
            },
            "searchPanes",
            "searchBuilder"
        ],
        select=True
    )
data = {
    'Title': ['1Password', '1Password', '1Password'],
    'Name': [12296, 24812, 25516],
    'AnyDateColumn': ['2023-04-19', '2023-04-18', '2023-04-18']
}

convert_to_table(data)

@pali07
Copy link
Author

pali07 commented Jun 10, 2024

Hi @mwouts Thanks for the quick reply

@mwouts
Copy link
Owner

mwouts commented Jun 10, 2024

Thanks for the detailed information! I can reproduce the issue, that's a first step. I think we should be able to add the datetime extension, cf. the linked PR, although it's not working right now...

At the moment I am getting the following error: Uncaught ReferenceError: assignment to undeclared variable dt (and no table can be displayed). I might have to see on the datatables forum for how to get this PR right. I will keep you posted.

@rsnell-usgs
Copy link

rsnell-usgs commented Jun 24, 2024

+1 for this issue. Same error for a table that includes dates as a column.

DataTables discussion on this:
https://datatables.net/forums/discussion/76107/searchbuilder-requires-datetime-when-used-with-dates#Comment_220274

@mwouts
Copy link
Owner

mwouts commented Jun 24, 2024

Oh that was helpful! I followed the first comment that points to the download builder and I could install the DateTime package.

@rsnell-usgs @pali07 feel free to use the install instructions at #289 (comment) to test the PR locally.

I am not going to merge this right now as I still see a small issue, I will discuss it with Allan on the PR.

@mwouts mwouts mentioned this issue Sep 3, 2024
@mwouts
Copy link
Owner

mwouts commented Sep 8, 2024

This issue has been solved in itables==2.1.5

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