mwouts / itables

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

Newest itables not displaying in static pages #233

Closed liquidcarbon closed 7 months ago

liquidcarbon commented 7 months ago

My pages broke after I upgraded from 1.5.3 to current. image

I'm building a table for listing files in a folder using itables:

    return (
        f"{navigation}"
        +
        to_html_datatable(
            df=res,
            classes="display compact",
            showIndex =False,
            paging=False,
            tableId=str(ULID())  # this is where "#01HR..." comes from
        )
    )

For some reason it doesn't like the #01HR... table ID, It actually works when it's not set, or when it's set to a string.

Perhaps it's a jQuery quirk? Is there a way to pin the version of jQuery used by itables?

Not sure if this is related, but the symptom of "loading ..." is similar: https://github.com/mwouts/itables/issues/216

mwouts commented 7 months ago

Oh I see - I've had similar issues while developing itables==1.7.0. I think querySelectorAll enforces id rules in a stricter way than the previous approach.

I read this: The id name must contain at least one character, cannot start with a number, and must not contain whitespaces (spaces, tabs, etc.) at https://www.w3schools.com/html/html_id.asp.

Maybe a simple workaround is to set tableId=f"U{ULID()}" ?

liquidcarbon commented 7 months ago

That's what I ended up doing, probably didn't even warrant an issue.

So I'll take a chance to say thanks for your work :)

Also, glad you're looking into compatibility with Quarto, I previously ran into the styling issues with datatables in Quarto-rendered pages. It appears to be solved now?

mwouts commented 7 months ago

That's what I ended up doing, probably didn't even warrant an issue.

No problem, that's always helpful - and since that's two of us encountering that issue I will add a warning for this (please don't close the issue until then).

So I'll take a chance to say thanks for your work :)

My pleasure, thanks for using it!

Also, glad you're looking into compatibility with Quarto, I previously ran into the styling issues with datatables in Quarto-rendered pages. It appears to be solved now?

Yes, it should be better with itables>=1.7.0. You can have a look at the two example documents in the documentation.