This content has been marked as final. Show 7 replies
Isn't this just about changing the height of the DataGrid?
erm... I dont think so...
I am trying to - for example.... if I only have 2 rows of data in the dataGrid, then I want to only display / include 2 rows of the datGrid (layout)...... i.e. I want to trim the amount of rows of the dataGrid to the number of rows that populate the dataGrid by the dataProvider etc...
although, I am new to Flex, so maybe missing something.... as far as I can tell, the "height" propertie of the dataGrid hyst adjusts the height displayed within the page ????
We must be getting crossed up on terminology. What I mean is, for example, a DataGrid's default height is something like 156 pixels. That's enough vertical room to display the headers plus 6 rows of data. Now, if your dataprovider has only 2 rows of data, there's still going to be 4 rows worth of extra vertical space below those two data rows in the grid. To get rid of that extra space, you'll have to reduce the height of the grid, right?
Or do you mean that you don't want the grid to paint the empty rows with alternating colours? That you just want it all to be white?
if my dataprovider has only 2 rows of data, there will still be 4 rows worth of extra vertical space in the grid below the two rows in the grid which I want to get rid of...... so then, yes you are right - I will have to reduce the height of the grid.
but the number of rows in the grid is not consistant (could be more than 2, could be less) depending on the dataProvider..... so I need the "height change" to by dynamic and relevent to the number of rows populated etc.
Then your only choice is to do a little math whenever you set the dataprovider. Get the number of rows, multiply by the number of pixels per row and set the grid's height to be that. Of course, you'll most likely have to put a max on the height as you can't just let the grid grow indefinitely.
Really, my advice would be to not bother. Having a grid that might be taller than the number of displayed rows is perfectly acceptable UI practice.
ok - thanks for your help inlineblue ... I understand what you are saying and dont think will bother trimming the datagrid.....
the only reason I asked was because eventually I want to allow the user to "add" a row to the DataGrid, and was thinking of including an "Add Row" button etc... allowing them to add a row, therefore trimming the dataGrid accordingly and adding an additional row to the bottom of the dataGrid when the button is selected.