reflex icon indicating copy to clipboard operation
reflex copied to clipboard

[REF-2738] Data table does not overflow

Open murdak opened this issue 1 year ago • 7 comments

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):

  • Python Version: 3.11.4
  • Reflex Version: 0.3.7
  • OS: linux
  • Browser (Optional): firefox

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

From SyncLinear.com | REF-2738

murdak avatar Jan 20 '24 22:01 murdak

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

murdak avatar Jan 25 '24 04:01 murdak

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

tankztz avatar Jan 28 '24 03:01 tankztz

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!

justicho avatar Apr 15 '24 19:04 justicho

@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.

picklelo avatar Apr 15 '24 19:04 picklelo

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!

justicho avatar Apr 26 '24 22:04 justicho

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}

Shuxley-jones avatar Apr 30 '24 12:04 Shuxley-jones

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.

picklelo avatar May 01 '24 19:05 picklelo