This is a migrated thread and some comments may be shown as answers.

How do I resize RadWindow containing RadGrid after paging and fewer rows returned

4 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randall
Top achievements
Rank 2
Randall asked on 18 Feb 2011, 04:15 PM
Hello,

RadControls For ASP.NET AJAX v2009.1.527.35

I have a RadWindow that contains a RadGrid for search results and a RadToolbar with a Search button.

The RadWindow auto-sizes when it is first displayed which is working fine.  The RadGrid has a page size of 10 rows, and allows paging.  Paging is working fine as well, but when I get to the last page (which has fewer than 10 rows) the RadGrid shrinks and leaves space below it.  I want the RadWindow to resize when this happens.  I have Javascript code to handle resiging the RadWindow so I would like do this client-side.  My problem is I don't know what event to hook into after the RadGrid paging so that I can then call the resize code.

I saw in this form mention of the "OnClientPageLoad" event for the RadGrid but apparently that is only in a newer version of RadControls, and unfortunately upgrading is not an option at this time.

I have attached screenshots showing what is happening.

Picture 1 shows the RadWindow resized correctly, picture 2 shows what happens on the last page when there are fewer rows.

Thanks,
Randall Price
Virginia Tech

4 Answers, 1 is accepted

Sort by
0
Randall
Top achievements
Rank 2
answered on 18 Feb 2011, 05:09 PM
I have resolved this issue on my own, and thought someone else may benefit from my solution.

I hooked into the RadGrid.OnGridCreated() event and use the following code to resize the RadWindow if the number of rows in the RadGrid changes from one page to another.  This works paging up and down, as well as changing the RadGrid.PageSize.

function OP_RadGrid1_GridCreated(sender, args) {
    var intNumRows  = sender.get_masterTableView().get_dataItems().length;
    var intPageSize = sender.get_masterTableView().get_pageSize();
    if (intNumRows != intLastRowCount) {
        intLastRowCount = intNumRows;
        AdjustRadWindow();
    }
}

Thanks,
Randall Price
Virginia Tech
0
Randall
Top achievements
Rank 2
answered on 18 Feb 2011, 08:05 PM
Not sure how to mark this post as Answered.
0
James
Top achievements
Rank 1
answered on 02 Feb 2013, 04:41 PM
Hi Randall,

I am facing the exact problem. Can you share what you do in the AdjustRadWindow() function please?
0
Randall
Top achievements
Rank 2
answered on 06 Feb 2013, 07:27 PM
Hi James,

Here is the Javascript for AdjustRadWindow() functionality you are asking about.  I have since changed the name somewhat and combined these functions into a Utils.js file, but still the same and should work for you.
function Utils_AdjustRadWindow() {
    setTimeout(function () {
        Utils_GetRadWindow().autoSize(true);
    },
    1000);
}
 
function Utils_GetRadWindow() {
    var oRadWindow = null;
    if (window.radWindow)
        oRadWindow = window.radWindow;
    else if (window.frameElement)
        if (window.frameElement.radWindow)
            oRadWindow = window.frameElement.radWindow;
    return oRadWindow;
}

Hope this helps!

Thanks,
Randall Price
Virginia Tech
Tags
Grid
Asked by
Randall
Top achievements
Rank 2
Answers by
Randall
Top achievements
Rank 2
James
Top achievements
Rank 1
Share this question
or