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

Only the first row is visible

Open mfeingold opened this issue 13 years ago • 24 comments

I copy pasted the code from the getting started page posted here - the grid shows up, but only the first row is visible, and even that not completely. It turns out that the div with the class ngViewport has its height explicitly set to 0. What am I doing wrong? How can I control the height of the visible portion of the grid?

mfeingold avatar Jan 03 '13 13:01 mfeingold

You need to manually set a height to your ngGrid class.

.ngGrid { height: 300px; }

sonicparke avatar Jan 03 '13 14:01 sonicparke

hmm... Essentially this way I will set height for all grids on my page - right? What if I have several grids with different sizes?

mfeingold avatar Jan 03 '13 18:01 mfeingold

Right. You'll probably need to add a class for each grid you want to set at a different height.

.ngGrid { height: 300px; }

.ngGrid.grid1 { height: 350px; }

.ngGrid.grid2 { height: 650px; }

Or something like that.

sonicparke avatar Jan 03 '13 18:01 sonicparke

and then what? The ngGrid class is assigned to an internal div by the ngGrid javascript programmatically. Is there a way to control it?

mfeingold avatar Jan 04 '13 01:01 mfeingold

The ngGrid class is added to the div that you use the ng-grid declaration on in your html.

Here's a plunker for an example: http://plnkr.co/edit/hUZvR3 There's some extra stuff in there but just look at the div's in the HTML that have the declaration of ng-grid="" on them.

sonicparke avatar Jan 04 '13 04:01 sonicparke

Sorry. This is a joke Plunker played on me. I changed the height on the grid div but Plunker decided to ignore the change. Only after I refreshed the entire thing the change actually took.

I got it now,

mfeingold avatar Jan 04 '13 13:01 mfeingold

Sorry the plunker didn't work. Apparently it stopped saving my changes late last night. So yes, the plunker was jacked up. Plunker seems to be having issues this morning also so I'm not yet able to fix it. On another note, I'm trying to help you. There's no need to be rude.

sonicparke avatar Jan 04 '13 14:01 sonicparke

Wow, man, no way I intended to be rude.

When I was talking about Plunker, it was about me using Plunker to play with my own stuff, not about your plunk. I plyed with the grid in my own plunk and it was throwing me off all the way, that's why I posted the issue.

I do appreciate your effort and you did point me in the right direction. If you feel slighted, I apologize, really. I am just learning the ropes here, and every step takes some effort, so when Plunker throws another monkey wrench I feel a little frustrated.

mfeingold avatar Jan 04 '13 14:01 mfeingold

Ah. No sweat. No worries. Yes, plunker does decide to jack things up sometimes. Now that I re-read your post I get it. Sorry about that.

I've had that happen to me before as we'll. Some things just decide to stop taking affect until you refresh the while page. It's frustrating. And it seems that now it won't save any of my changes not sure if it's plunker or I just need to reboot.

I'm glad you got it working though. It's very nice when you get something working and can move in to the next piece.

On Jan 4, 2013, at 8:38 AM, Michael Feingold [email protected] wrote:

Wow, man, no way I intended to be rude.

When I was talking about Plunker, it was about me using Plunker to play with my own stuff, not about your plunk. I plyed with the grid in my own plunk and it was throwing me off all the way, that's why I posted the issue.

I do appreciate your effort and you di point me in the right direction. If you feel slighted, I apologize, really. I am just learning the ropes here, and every step takes some effort, so when Plunker throws another monkey wrench I feel a little frustrated.

— Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/ng-grid/issues/80#issuecomment-11884680.

sonicparke avatar Jan 04 '13 14:01 sonicparke

Actually, the real issue is the that the script is interpreting height: auto; (the default) as height: 0; and falling through to min-height which is set to 20px in the css that comes with the package. This value then gets written in as an inline style for some reason. You can override that behavior by using height: auto !important; until this bug is resolved in the JS (by please not writing a height to the inline style). Doing that will remove the need to for separate, manually updated heights for each grid.

I should note for those who aren't aware and reading this from Google or something that the use of !important is very very bad practice, but I'm cool with it here as a work around while the script is being updated so frequently. Thanks for that by the way.

robspages avatar Jan 04 '13 14:01 robspages

I am not sure if this is the right thing to do, but I got my answer and therefore I feel like closing this issue

mfeingold avatar Jan 08 '13 13:01 mfeingold

the height: auto !important workaround is not working for me.

davidjnelson avatar May 11 '13 00:05 davidjnelson

Experienced this today, did someone forgot to fix this before closing the issue?

Dashue avatar Jun 24 '13 17:06 Dashue

any updates on this issue???

Hello,

i am adding rows dynamically to ng grid.

issue: i have around 24 existing records in my ng grid. i can see only see one row that i have added. when i added more rows.. rows are not showing in ng grid, when i increase the height of ng grid via developer tool i can see the rows that i have added . it seems that ng grid is not dynamically increasing the grid height when we are adding more rows.

i have one parent div in which height is set to 650 px then i have ng grid which has height and width= 100%

its like

i tried auto option for height also in parent div as mentioned in https://github.com/angular-ui/ng-grid/issues/80..but no success

Please advise as this is very critical for us.

thanks

HTML Structure:

""div id="div-report" class="report-container" div class="gridStyle" ng-grid="gridOptions" div div

CSS: .report-container { margin:0px; width:100%; overflow:hidden; position:relative; height:600px;

}

.gridStyle {
width: 100%; height: 100%;

}

vinaynijhawan avatar Jul 08 '13 13:07 vinaynijhawan

height: auto !important is not working. As of now i am using min-height option to show all my records. Is this issue fixed?

There is a trick to calculate the height depending on the no.of records in the gid. Default row height is 30px and default header row height is 32.

So if you have 10 records, then the height of your grid is 10*30 + 32 = 332.

Calculate the height by using your data like [(gridData.length)*30 + 32](here gridData is the object you are assigning to your grid) and use some jquery code in your js file to assign this height to your gridStyle class.

ranadheerrannu avatar Sep 06 '13 11:09 ranadheerrannu

I guess you cannot call it "best practice" but for my very specific needs, this css workaround is was enough:

.ngViewport.ng-scope{
    height: auto !important;
    overflow-y: hidden;
}

.ngTopPanel.ng-scope, .ngHeaderContainer{
    width: auto !important;
}

eitankw avatar Oct 06 '13 19:10 eitankw

Thanks eitankw, this works!

ghost avatar Oct 11 '13 18:10 ghost

I used eitankw's solution with a minor change:

.ngViewport.ng-scope{
    min-height: 200px !important;
}

It worked, but then requirements changed and I had to increase the min-height to 400px. When loading up the grid, there is a scroll bar down the right side that is the full 400px, but the rows stop about halfway down the viewport (6 rows are visible). When the browser window is resized, the rows suddenly fill the full 400px.

It's no different with height or min-height, and all parent containers are at least 400px in height. Is there a reason why it would fix the first time, but not the second?

strangeapparition avatar Nov 15 '13 22:11 strangeapparition

In 2.0.7 the following works for me: .gridStyle { border: 1px solid rgb(212,212,212); height: 100% !important; }

.ngViewport.ng-scope { height: 100% !important; }

The following is because i want it to occupy the whole page in width:

.ngViewport.ng-scope > .ngCanvas { width: 100% !important; }

.ngViewport.ng-scope > .ngCanvas > .ng-scope { width: 100% !important; border-bottom-width: 0px !important; }

dalvarezmartinez1 avatar Apr 03 '14 15:04 dalvarezmartinez1

Hi I use this code : .gridStyle { direction: rtl; border: 1px solid rgb(212,212,212); width: 846px; height: auto; }

.ngViewport { height: auto !important; min-height: 200px !important; } But there were only 6 rows, the first time I ran the program

SamiraJafari avatar Jun 22 '14 12:06 SamiraJafari