mwouts / itables

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

How to wrap content in the cell ? #24

Closed CavemanWork closed 2 years ago

CavemanWork commented 3 years ago

Version: itables==0.3.0

Code:

import itables
import itables.options as opt
opt.classes = ["display", "cell-border"]
opt.maxBytes = 2**20
itables.show(
    bg_all_df, scrollY="800px", scrollCollapse=True, paging=False
)

Issue: If the text lenght larger than threshold if found that the tail will cutdown. how to show the full centent in the cell without wrap?

CavemanWork commented 3 years ago

Any update ?

mwouts commented 3 years ago

Hi @CavemanWork , well below are some experiments, please let me know if any of them is close to what you want to do...

If we do

import itables
import itables.options as opt
import pandas as pd

opt.maxBytes = 2**20
bg_all_df = pd.DataFrame({"text":["long " * 128 + "text"]})

opt.classes = ["display", "cell-border"]
itables.show(
    bg_all_df
)

the cell content is wrapped image

Now if we do

opt.classes = ["display", "nowrap"]
itables.show(bg_all_df)

then it appears truncated: image

And finally if we set a custom width (but I don't know how to set the width automatically, maybe you can ask at https://datatables.net ?) we can scroll horizontally:

itables.show(bg_all_df,  columnDefs=[{"width": "4000px", "targets": "_all"}])

image

Hope that helps!