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

fix: adjust the left/right canvas width properly when fullWidthRows is used #664

Conversation

xinchao-zhang
Copy link
Contributor

@xinchao-zhang xinchao-zhang commented Jan 28, 2022

When fullWidthRows: true is used in options, and when the viewport width is larger than the canvas width, slick grid does not create rows wide enough to fill the viewport.

This happens because although the total canvas width has been calculated to match that of viewport, the total canvas width is not distributed to the left/right canvas.

To illustrate:

Without the fix and with this option: { fullWidthRows: true } , there is an area of white space at the right side of the canvas (selected row is colored in blue to make it more obvious):
current

And with this option: { fullWidthRows: true, frozenColumn: 2 }:
current_with_col_freeze

Basically visually the fullWidthRows has no effect.

With the fix and with this option: { fullWidthRows: true }:
fix
Same for frozen columns { fullWidthRows: true, frozenColumn: 2 }:
fix_with_column_freeze

@xinchao-zhang xinchao-zhang force-pushed the bugfix/canvas-width-calculation-under-full-width-rows branch from ec50cc8 to ae7e1cb Compare January 28, 2022 14:00
@ghiscoding
Copy link
Collaborator

ghiscoding commented Jan 28, 2022

@xinchao-zhang
can you show print screen or animated gif of what that fixes? it's hard to see what would be the difference just in code. I tried your code in my libs and I don't see any differences, so I don't know what to look for

@xinchao-zhang
Copy link
Contributor Author

@ghiscoding I've updated my original comment with screenshots

@ghiscoding
Copy link
Collaborator

ok that's much better to understand, but I wonder why do you think it's better with the fix and what is your use case?
I kind of prefer without the fix, if I select a row I don't really want it to go outside the columns (same goes for background coloring), isn't it better to just change the viewport width of the grid?

@xinchao-zhang
Copy link
Contributor Author

This renders the data grid in a way more similar to e.g. Excel. In my view it just makes the grid looks more polished. We don't always have the luxury/flexibility to shrink the viewport in order to get rid of the white space. E.g. the grid might be only a part of a larger layout and the size of the grid viewport is decided externally and dynamically (think flexbox). Meanwhile the column set can change dynamically as well (e.g. user can add or remove or resize the columns at runtime) so it is hard to always statically fix the viewport size.

But most importantly, what does fullWidthRows option supposed to do then lol? Do you mean you would prefer removing the fullWidthRows feature?

@ghiscoding
Copy link
Collaborator

oh right I forgot you mention that it's with the fullWidthRows grid option enabled, that's my bad I read it too quickly (I have never tried that option actually). So in that case I would agree with you then. Let see if @6pac has any opinions on the subject.

@6pac
Copy link
Owner

6pac commented Jan 29, 2022

Wasn't aware it even existed!

@6pac
Copy link
Owner

6pac commented Aug 1, 2022

This looks good to me. OK to proceed @ghiscoding ?

@ghiscoding
Copy link
Collaborator

I'd be ok with it

@6pac 6pac merged commit d3de81c into 6pac:master Aug 3, 2022
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

Successfully merging this pull request may close these issues.

3 participants