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

Adjusting RadWindow size on client action issues

1 Answer 108 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 29 Mar 2011, 10:26 PM
Hi Telerik,

I have a RadWindow of a certain size. When the RadWindow is first loaded I call AdjustRadWindow to set the window size. In addition, the window adjusts fine on a RadDateTimePicker's OnPopupOpening and OnPopupClosing events.

I am struggling to get this to work when the user interacts with a RadComboBox. The RadComboBox hides elements on the RadWindow and I would like to resize the window after they're hidden.

protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    SetWindowState(RadComboBox1.SelectedValue);
}
 
private void SetWindowState(string currentSelection)
{
    if (string.Compare(currentSelection, Charts.LineChart.ToString()) == 0)
    {
        RadDateTimePicker2.Visible = true;
        Label2.Visible = true;
        CheckBox3.Visible = true;
    }
    else if (string.Compare(currentSelection, Charts.PieChart.ToString()) == 0)
    {
        RadDateTimePicker2.Visible = false;
        Label2.Visible = false;
        CheckBox3.Visible = false;
    }
    else
    {
        Debug.Assert(false, "Unhandled chart type in RadSettings");
    }
}
function OnClientSelectedIndexChanged(sender, eventArgs) {
    setTimeout(function () { AdjustRadWindow(); }, 500);
}

function AdjustRadWindow() {
    var oWindow = GetRadWindow();
    setTimeout(function () { oWindow.autoSize(true); if ($telerik.isChrome || $telerik.isSafari) ChromeSafariFix(oWindow); }, 500);
}
 
//fix for Chrome/Safari due to absolute positioned popup not counted as part of the content page layout
function ChromeSafariFix(oWindow) {
    var iframe = oWindow.get_contentFrame();
    var body = iframe.contentWindow.document.body;
 
    setTimeout(function () {
        var height = body.scrollHeight;
        var width = body.scrollWidth;
 
        var iframeBounds = $telerik.getBounds(iframe);
        var heightDelta = height - iframeBounds.height;
        var widthDelta = width - iframeBounds.width;
 
        if (heightDelta > 0) oWindow.set_height(oWindow.get_height() + heightDelta);
        if (widthDelta > 0) oWindow.set_width(oWindow.get_width() + widthDelta);
        oWindow.center();
 
    }, 310);
}

If I place an alert inside of OnClientSelectedIndexChanged then, after I close the alert, AdjustRadWindow seems to work properly. The problem is that the controls aren't disappearing fast enough from the screen, even with two time-outs.

I believe the issue may be related to this -- http://www.telerik.com/community/forums/aspnet-ajax/ajax/slow-ajax-response-wondering-if-i-can-do-something-to-improve.aspx

Any suggestions? Solutions?

Thanks

Sean

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 31 Mar 2011, 11:57 AM
Hi Sean,

Based on the provided information I cannot replicate your scenario. I can only be guessing but please check if a postback occurs after a click on the combobox. If it does it is possible that the alert blocks it so you see the changes, but then the page postbacks and the window resets.
If this does not help you solve the issue please send us a fully runnable project that displays this behavior so we can debug it locally and pinpoint the issue.


Regards,
Marin
the Telerik team
Tags
Window
Asked by
Sean
Top achievements
Rank 2
Answers by
Marin Bratanov
Telerik team
Share this question
or