I have a grid whose height is set on server side while it loads. The grid also have filtering which will show few rows (less than 5) when filter applied.
The problem is when the filter is applied and the grid height is unchanged, the rows span over the available height of the grid with more space between the rows. I want to avoid this space and have all the rows together. If any one knows a solution, please help.
Setting the DisplayLayout.TableLayout or DefaultRowHeight doesnt give me what I desire as I cant know the size of a row which depends on the contents of the cells.
Can you please suggest me a solution which will just do
The problem here is that you're re-sizing the grid to be the entire height of the page. If a height is set on a table (which is what you're doing when you resize on the client-side), the table will attempt to fill itself with the rows added to it. Try setting DisplayLayout.TableLayout=fixed, along with a DefaultRowHeight on the grid. That may enable the scenario you're looking for.
This may also be a case of forcing the grid to 'refresh' during a filter process. Since the grid only re-loads its data and not the entire HTML footprint, it's not going to take the sizing that you're putting in place on the server.. To get the ENTIRE grid to re-render, you'll need to use an UpdatePanel or force a full page postback.
Hope this helps,
-Tony
Hi Tony,
I dont have the DefaultRowHeight set any where, I use wrap on cells so the height of the row depends on the contents of the row.
I use the following code to set the height of the grid in the code behind (c#) initially
{
}
Then I use the javascript to set the height of the grid to the available height of the browser on onresize event of the window
gridHeight= clientHigh-125;
grid.resize(grid.MainGrid.offsetParent.offsetWidth - 4, gridHeight)
I get scrolling within the grid and page doesnt have scrolling and it looks good when I have many rows.
Then if I apply filter on the column to show only 3 rows, these 3 rows will occupy the whole height of the grid with 1/3 of height for each row.
I want the height of the grid to automatically change acording to the content of the rows and if the content exceeds the page available height then have a scroll bar within the grid.
Any help will be much appreciated.
Thanks in advance.
Do you have a DefaultRowHeight set? Also, how are you setting the height on the grid? Be sure that you set the grid.Height and the grid.DisplayLayout.FrameStyle.Height to the same value.