Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grid.auto_fit_columns not working #302

Closed
joseberlines opened this issue Mar 3, 2022 · 12 comments
Closed

grid.auto_fit_columns not working #302

joseberlines opened this issue Mar 3, 2022 · 12 comments

Comments

@joseberlines
Copy link

joseberlines commented Mar 3, 2022

I got the code from the example related to auto_fit_columns and I get the following:

image

As you see the code is the same as in:
https://github.com/bloomberg/ipydatagrid/blob/main/examples/Column%20Width%20Auto-Fit.ipynb
but I changed just one line to make the words langer.

The result is that applying:
grid.auto_fit_columns = True

does not change anything and the content of the cells is cut as if nothing would have been changed.

Some idea what I am doing wrong?

THIS IS WHAT i WOULD HAE EXPECTED:
image

thanks

@ibdafna
Copy link
Member

ibdafna commented Mar 11, 2022

Hello @joseberlines , I tested this functionality locally and it appears to be working fine. Can you check your installation, perhaps you're on an older version?

auto_fit_columns

@ibdafna
Copy link
Member

ibdafna commented Mar 16, 2022

@joseberlines can you check the browser console and let me know if you see any errors there?

@joseberlines
Copy link
Author

I will report soon. we have ipydatagrid in a JupyterHub environement and indeed the version currently is not the last one.

@joseberlines
Copy link
Author

joseberlines commented Mar 17, 2022

Hi @ibdafna
So version updated to 1.1.11 and this is the result:
image

code gist:
https://gist.github.com/joseberlines/694259ce8299e179cdc1877e6baaccbd

What I find strange:
a) the auto ajustment does not work fully. The table is created first small and when running:
g.auto_fit_columns = True
columns are getting more width but not entirely.

b) Since wraptext = True I would expect al least to go over several lines WITHIN a cell.

Putting info all together (and even if I am mixing up two things here)

  1. I am looking for a way to auto adjust all the content of all the cells.
  2. Ideally there should/could be a way to tell ipydatagrid: max width is 90px (or whatever) and from there wrap the text contained in a cell into new lines within the cell.

This would be pretty much like Excel and it would be a great enhancement.

Moreover, in the above code I made the rows bigger as this:
image

And the way autofit columns works together with wrap text is puzzeling.
We had this issue still open here:
#210 & #294

but following instructions there I thought the wrapping would be working.

Please let me know if you need/want more information or insights regarding my explanation

@matangover
Copy link

I can reproduce this easily by copying the code from the example notebook posted above, and adjusting the column contents to long values instead of the given short values. @ibdafna The GIF you showed shows resizing only by the column headers. The problem is when wanting to resize by the column contents.

I'm using version 1.1.11 and I don't see any errors in the console. Thanks!

@matangover
Copy link

Screenshot -
I would expect "col1" to be resized based on the cell contents.

image

@matangover
Copy link

(Perhaps this is simply a missing feature)

@ibdafna
Copy link
Member

ibdafna commented Apr 13, 2022

@matangover Okay, yes, the auto sizing works only based on the columns, not the cells. I misunderstood the question. @joseberlines looking at your screenshot, you have the text_wrap feature set to true on the header_renderer TextRenderer object, which applies only to the column headers. You need to set this for the default renderer. You can use default_renderer = <some_textrenderer_instance> if you want to this apply to all cells. Or you can do this based on a column. I believe the documentation has a few examples. Thanks!

@vthemelis
Copy link
Contributor

vthemelis commented Jan 26, 2023

@ibdafna, would it be possible to have some sort of option that will allow auto-adjusting the length of the columns based on the content rather than the column headers?

Effectively, I'm looking for what you get in Excel when double clicking the line that splits two adjacent rows in Excel.

At first, this can be provided through a programmatic API, but ideally, it would be great to auto-adjust the length by double clicking on the GUI.

I could start implementing this myself if you don't morally disagree with the change.

@vthemelis
Copy link
Contributor

Added jupyterlab/lumino#546 that implements the functionality described in this.

@vtgruk
Copy link

vtgruk commented Aug 17, 2023

jupyterlab/lumino#546 is now released in JupyterLab https://github.com/jupyterlab/jupyterlab/releases/tag/v4.0.5 . I think we can now close this issue.

@martinRenou
Copy link
Member

Closing as it's now possible to double click on the column separators to auto-fit content, thanks a lot @vthemelis !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants