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

UI-Grid minRowsToShow not show in refresh() #2531

Closed
enkhi77 opened this issue Jan 11, 2015 · 12 comments
Closed

UI-Grid minRowsToShow not show in refresh() #2531

enkhi77 opened this issue Jan 11, 2015 · 12 comments

Comments

@enkhi77
Copy link

enkhi77 commented Jan 11, 2015

After changing the minRowsToShow in gridOptions and running a gridApi.core.refresh(), the grid still keeps to the old value even though a console.log() shows that the gridOptions.minRowsToShow has changed.

@PaulL1
Copy link
Contributor

PaulL1 commented Jan 14, 2015

This sounds like another flavour of #1819. What would you expect the grid to do when you changed minRowsToShow?

@PaulL1 PaulL1 added this to the 3.0 milestone Jan 14, 2015
@enkhi77
Copy link
Author

enkhi77 commented Jan 15, 2015

I think that when minRowsToShow changes that it should refresh the grid to reflect the new minRowsToShow. Refresh might not be the right word as currently if you change the minRowsToShow you have to fully reload the page to reflect the change. It may just have to do with how the core.refresh() reads the gridOptions, but it would be great if that was reflected on the refresh.

@jonrimmer
Copy link

I would also like this feature. minRowsToShow seems to be misnamed, as it's not a minimum, it's just the number of rows the grid auto-sizes itself to show, so rowsToShow would be more accurate.

However, the ideal number of rows to show isn't always known at startup, and may change over time. For example, if I'm using the grid to show the results of a web service call, then the number of rows will depend on the data I get back. If I only have a single entity to show, then rowsToShow would be one. If I have a thousand, then I might want to set it to ten or twenty.

As it stands, I have copied the auto-sizing logic from the grid into a custom directive, that watches minRowsToShow and does the auto-size every time it changes. This works, but it would be nice if the grid itself supported this behaviour, or at least exposed the auto-sizing ability in a way that I could call, rather than having to copy the code into my own directive.

@br0dieman9
Copy link

I agree, I would also like this behavior. I think that minRowsToShow should default to 1, and there could be a rowsToShow setting that you could set for the desired page size (10 or 20 for example). If the length of the data bound to the grid is less than rowsToShow, minRowsToShow should be set to the length of the data array.

On another note, I also think that the scroll bar settings (horizontal and vertical) and the menu settings (both grid and column level) should default to off.

@ghost
Copy link

ghost commented Feb 26, 2015

@jonrimmer Would you mind posting that custom directive? Would save me a few minutes of digging. :) Resizing the grid seems to be my next best option instead of forcing the scrollbars to be always on.

@jonrimmer
Copy link

@kcaron-cst No problem, here you go: https://gist.github.com/JonRimmer/d9c9091a9c300286a8ef

@ghost
Copy link

ghost commented Feb 26, 2015

@jonrimmer Awesome, thanks so much. Worked great for me with a couple edits to account for enablePagination and showColumnFooter.
https://gist.github.com/kcaron-cst/064a8e890b0e30052012

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 28, 2015

Sounds like another flavour of #3031, tying them all together so if anyone works on it they can find them all.

@PaulL1 PaulL1 modified the milestones: Future, 3.0 Mar 28, 2015
@StevenDewey
Copy link

I would also like this feature.

I ended up doing a pretty hackish work-around by finding the elements that needed their height be expanded to fit the new rows, and then multiplying the number of rows by the height of the row and then setting the height of the elements to the total. It looks something like this:

heightValue = numberOfRows * heightOfRow + 'px';
var grid1 = document.getElementsByClassName('grid ui-grid');
grid1[0].style.height = heightValue;
var grid2 = document.getElementsByClassName('ng-isolate-scope ui-grid-viewport');
grid4[0].style.height = heightValue;

this is called each time the number of rows changes and thus the height of the grid is always updated dynamically... Good luck

@deeg
Copy link

deeg commented Jan 22, 2016

If minRowsToShow works when rendering the grid, it would be really nice to be able to update that number when changing data so the height of the grid can change. Is this something you guys would consider putting in if PRs were submitted?

@stale
Copy link

stale bot commented May 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 23, 2018
@stale
Copy link

stale bot commented Jun 22, 2018

This issue has been automatically closed because it has not had recent activity. If you believe that this is still an issue in the latest version, feel free to re-open it. Thank you for your contributions.

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

No branches or pull requests

6 participants