ASPxGridView change height on resize, possible?

neuDev33 picture neuDev33 · May 17, 2012 · Viewed 8.3k times · Source

I have an ASPxGridView with SettingsPager set as

Mode = ShowAllRecords, PageSize = 100000, CurrentPageNumberFormat = '', Visible = False

What I want is to have all the records display with a scroll bar and have no page size at all.

When the containing parent DIV tag is resized the Grid should also adjust it's height. Currently, I see a few records, as many as would fit into the size of the parent div. However, when I resize, I still see the same number of records and empty gray portions at the top and bottom. If the grid does not have a pagesize, I should just be able to see the rows below, right?

EDIT:

Here's what I've tried -

grid.setHeight(newHeight);
grid.AdjustControls();

and also the solution mentioned here, which works fine to set the initial height.

Answer

saluce picture saluce · May 17, 2012

See this sample on DevExpress website to do what you want.

EDIT: To do the same thing when resizing the containing div, rather than just the browser window, change the JavaScript code to:

<script type="text/javascript">
    function adjustSize(newHeight) {
        grid.SetHeight(newHeight);
    }
</script>

Then, in the JavaScript that resizes the height of the container div, call adjustSize(newHeight) to adjust the size of the grid to match.

Or, more simply, just call grid.SetHeight(whateverSize) in the same block of JavaScript you use to resize the div.