New joiner to dash-table-experiments

Hi Team,

I am new to Dash dash-table-experiments. I have two simple questions

  1. Is there a way to customize column width we could have dynamic column length in the dataframe.

  2. On the same level as the “Filter Rows” button, is there a way to add a button to export the table in excel?

Thank you.

Allen

Thanks for writing in! I’m a bit unclear about both of these questions.

For 1, is this an issue with automatic column width, or with dynamic column length? If you have a simple reproducible example about column widths (i.e. you’re not getting the width you’re expecting), I would create an issue for that.

Dynamic column lengths are a bit trickier. I would more clearly specify the action you’re looking for, and then create an issue (or see if anyone else in the community has had similar problems as you.) Datatables are meant to correspond to existing tables. One possible thing to think about would be a callback that recreates the entire datatable component if it notices a change in the data.

In terms of exporting data, I would research creating CSV files and serving them via flask. Then, you can just simply create a link to a created csv. This is an example of a stackoverflow question addressing this issue.

Thank you very much Charley.

For 1, I have ten columns in DataFrame and I would like them to show nicely (perfectly fit) on your Dash Table Experiment Framework. Depends on situations (e.g. some columns could have less width, e.g. Country Code, whereas I would like to see complete thing on $$ amount) I would like to have ability to configure width for each table cell.

Are you imagining columns having a fixed width no matter what the input is? I could imagine confusion occurring when columns are fit to one wide outlier cell.

If something like that solves your problem, that could be input as an issue on dash table experiments: https://github.com/plotly/dash-table-experiments Otherwise, it would be useful to think more about what you’re expecting the table to do.

My wish is simple - some column doesn’t need fixed width and can be shrink to accommodate other longer columns.

I want to have a way to customize using dash framework in field level.

Do you have any good ideas?

If you’re looking just to shrink columns based on other longer columns, you could use the existing column_widths argument in DataTable. All the columns will be fixed, but one column will be based on the widths of the other columns and the total width of the datatable. For example, if I had a DataTable like this:

ROWS = [
    {'a': 'AA', 'b': 1, 'c': 3},
    {'a': 'AB', 'b': 2, 'c': 4},
]

dt.DataTable(
    rows=ROWS,
    columns=['a', 'b', 'c'],
    column_widths=[200, 400, 400]
)

I could redefine it based on a total width of 1000

totalWidth = 1000
aWidth = 200
bWidth = 400

ROWS = [
    {'a': 'AA', 'b': 1, 'c': 3},
    {'a': 'AB', 'b': 2, 'c': 4},
]

dt.DataTable(
    rows=ROWS,
    columns=['a', 'b', 'c'],
    column_widths=[aWidth, bWidth, totalWidth - aWidth - bWidth]
)