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

5 posts, 0 answers
  1. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 18 Feb 2011 Link to this post

    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
  2. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 18 Feb 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 18 Feb 2011 Link to this post

    Not sure how to mark this post as Answered.
  5. James
    James avatar
    7 posts
    Member since:
    Jan 2013

    Posted 02 Feb 2013 Link to this post

    Hi Randall,

    I am facing the exact problem. Can you share what you do in the AdjustRadWindow() function please?
  6. Randall
    Randall avatar
    54 posts
    Member since:
    Jun 2008

    Posted 06 Feb 2013 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017