ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

[3.0] Grid will not render all rows - scrolling has no effect

Open mohammedshafiq opened this issue 12 years ago • 8 comments

I raised a bug earlier that the rows were not rendering correctly in version 2. I've now upgraded to 3.0 and facing similar issue.

I have multiple pages in my application and some display the table data using ui-grid. One grid has a hundred items and the others have no more than 10.

The grid initial loads and renders ok but when I navigate away and then return only 4 rows are rendered and there are no scroll bars to scroll the table.

I am using a MAC and see the issue in Chrome and firefox.

Any ideas? What extra information can I provide to help with debugging/fix.

mohammedshafiq avatar Sep 26 '14 18:09 mohammedshafiq

@mohammedshafiq : @c0bra did a fix in the last couple of days in this area for a grid that was only part rendering and had a description that sounded like this. I can't see the merge right now, but I recall it. I wonder if it's worth retesting to see if this is still a problem.

PaulL1 avatar Oct 01 '14 00:10 PaulL1

Thanks PaulL1,

I've downloaded the latest release (rc11) of ui-grid and replaced the previous version (rc10) (I hope this is right).

I'm getting the same issue.

I have multiple grids in my app. When I first navigate to the grid (100 rows) it renders fine. I navigate away to another grid (10 rows) it renders fine. I navigate back to the first grid - it displays only 5 rows of the 100.

The data is coming async via the backend. I can see that all 100 data rows are loaded.

Thanks.

mohammedshafiq avatar Oct 01 '14 06:10 mohammedshafiq

Are you able to create a plunkr that demonstrates the problem? That would help in debugging.

(Actually, thinking about that - not sure what the update cycle is on the distributed version. Is it possible you could clone the repository, then npm install, bower install, then grunt, then copy dist/release/ui-grid.js across and test that?)

PaulL1 avatar Oct 01 '14 06:10 PaulL1

Cloned the repo and build the latest release and used as above and I get the same issue.

I will try and do a plunker and see how far I get. Any good starting points for plunker and ui-grid I can use?

mohammedshafiq avatar Oct 04 '14 22:10 mohammedshafiq

Easiest way is usually to pick a tutorial, and then edit in plnkr.

PaulL1 avatar Oct 04 '14 22:10 PaulL1

I think I solved the issue.

I debugged the ui-grid code and I found that the issue revolves around the grid.gridHeight which is calculated to 0 and hence causing the issues I am seeing. The method Grid.prototype.getViewportHeight then returns a negative number which breaks the grid.

In the directive uiGrid a default height is set on the element (300px in this case) but when getStyles is called further in the stack - it returns zero even though a height of 300px is present for the element.

To solve the issue I placed a height on the parent div containing the grid.

My markup was this:

<div class="row-fluid">
   <div id="mypropertieslist" class="gridStyle" ui-grid="gridPropertiesList" ui-grid-edit></div>
</div>

Changed to below

<div class="row-fluid" style="height:500px;">
   <div id="mypropertieslist" class="gridStyle" ui-grid="gridPropertiesList" ui-grid-edit></div>
</div>

Hope this helps to find the bug - please let me know if it was something I was doing wrong

Thanks

mohammedshafiq avatar Oct 05 '14 19:10 mohammedshafiq

That's interesting. The dynamic resize tutorial has a height on the grid, but changes when that height changes. So perhaps the approach to a resizeable grid is to have a height on your grid, but write some code to resize it when your window resizes?

I'm not sure quite what @c0bra had in mind there, but maybe it'd make sense to have some logic in the grid that basically sizes it to it's containing element or something like that? But thinking about that, often the containing element will size to the grid, so it becomes a bit circular.

PaulL1 avatar Oct 05 '14 22:10 PaulL1

If the grid detects that its height is less than that of one row (based on the default rowHeight), then it will resize itself to fix minimum 10 rows (overrideable with minRowsToShow).

@mohammedshafiq check out this plunker demonstrating it: http://plnkr.co/edit/tHCM0TBpipcQ2vEhdu6d?p=preview

I'm closing for now. Let me know if you still have the issue.

c0bra avatar Oct 06 '14 16:10 c0bra