reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
19.15k stars 1.08k forks source link

[REF-2738] Data table does not overflow #2426

Open murdak opened 8 months ago

murdak commented 8 months ago

Describe the bug When using a long column (>30), data table does not overflow and fits table to page.

To Reproduce Steps to reproduce the behavior: Create a data table with the column attribute set with a list of more than 30 elements.

rx.data_table( columns=["ID", "Name", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" ], data=[ ['0001', 'name1', '5:00 am'], ['0002', 'name2', "6:00 am, 4:00 pm", "6:00 am", "6:00 am, 4:00 pm", "6:00 am, 4:00 pm",],], ),

Expected behavior Data table overflows and shows data properly.

Screenshots If applicable, add screenshots to help explain your problem.

image

Specifics (please complete the following information):

Additional context Add any other context about the problem here. none

From SyncLinear.com | REF-2738

murdak commented 7 months ago

https://gist.github.com/murdak/e80cceb1306a9b46694b1a259e2162be

tankztz commented 7 months ago

I can reproduce this issue. But still don't know the root cause.

Somehow the "min-width" and "width" are missing from the table head column. Our compiled JS code is correct and is same as the sample where I tested and works properly. https://gridjs.io/docs/integrations/react

I can provide a workaround: I found adding a pagination can fix it - sometimes

justicho commented 5 months ago

Hello! My team(for class) would like to look into this issue and hopefully find the root cause. If you guys have any tips, that would be greatly appreciated!

picklelo commented 5 months ago

@justicho sounds great! The component is based on the GridJS React component under the hood, so a good place to start may be to see how to achieve this in GridJS. Then it should be easy to make the necessary changes in Reflex.

justicho commented 4 months ago

Unfortunately, we also weren't able to implement any changes due to our lack of time. But from what we’ve gathered, it seems that Reflex does indeed lack explicit min-width/width handling, which is crucial for correct display. Further recommended steps would be inspecting applied CSS in the browser when compiling the OG code and potentially extending datatable.py in the GridJS component of Reflex for explicit column width control, considering how Reflex translates Python properties to Grid.js configurations. And a big thank you to “picklelo” and “tankztz” for the help/advice!

Shuxley-jones commented 4 months ago

Experiencing the same issue, attempting to display a pandas pivot table (3 columns represented per hour, so up to 36 total columns in a typical day for my project). GridJS has an "autoWidth: true" for wide tables, which doesn't seem to apply to the Reflex component as we don't get the horizontal scroll bar.

Edit: I checked the page .js file in .web/pages and the DataTableGrid has autoWidth={true}

picklelo commented 4 months ago

I found this issue is solved by setting the style prop for the table:

 <DataTableGrid style= {{ 
    table: { 
      'white-space': 'nowrap'
    }}
  } columns={["ID", "Name", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"]} data={[["0001", "name1", "5:00 am"], ["0002", "name2", "6:00 am, 4:00 pm", "6:00 am", "6:00 am, 4:00 pm", "6:00 am, 4:00 pm"]]}/>

We don't currently expose this prop on our component - once we do it should be possible to set. And we should probably even set this as the default.