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

Window Behaviour after AJAX Request

3 Answers 124 Views
Window
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 11 Mar 2009, 11:41 AM
Hello,

I launch the windows from image buttons in a template column in a radgrid (located in a content page that inherits from a masterpage). When I click the cancel buttons on the window and simply close the window, the original settings i specify are maintained. However, when I click a button that does something then executes an ajax request to refresh the underlying grid, every window I open loses the settings I previously defined.

My RadWindowManager/Window setup:

<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Behavior="None"  
                InitialBehaviors="Pin" KeepInScreenBounds="True" Modal="True"  
                PreserveClientState="True" ReloadOnShow="True" ShowContentDuringLoad="False"  
                VisibleStatusbar="False"
                <Windows> 
                    <telerik:RadWindow Skin="Vista"  ID="InsertTaskWindow" runat="server"  
                        Title="Criar Tarefa" Height="620px" 
                        Width="750px" Left="" Modal="true" Overlay="True"  
                        ShowContentDuringLoad="False" Behavior="None" Behaviors="None"  
                        InitialBehavior="Pin" InitialBehaviors="Pin" ReloadOnShow="True"  
                        VisibleStatusbar="False" KeepInScreenBounds="True"  /> 
                    <telerik:RadWindow Skin="Vista"  ID="EditTaskDialog" runat="server"  
                        Title="Editar Tarefa" Height="620px" 
                        Width="750px" Left="" Modal="true" Overlay="True"  
                        ShowContentDuringLoad="False" Behavior="None" Behaviors="None"  
                        InitialBehavior="Pin" InitialBehaviors="Pin" ReloadOnShow="True"  
                        VisibleStatusbar="False" KeepInScreenBounds="True"  /> 
                    <telerik:RadWindow ID="ConfimTaskDialog" runat="server" Behavior="None"  
                        Title="ConcluĂ­r Tarefa" 
                        Behaviors="None" InitialBehavior="Pin" InitialBehaviors="Pin"  
                        Height="150px" 
                        Width="300px" VisibleStatusbar="False" 
                        KeepInScreenBounds="True" Left="" Modal="True" NavigateUrl=""  
                        ReloadOnShow="True" ShowContentDuringLoad="False" Top="" Skin="Vista"
                    </telerik:RadWindow> 
                    <telerik:RadWindow ID="ValidateTaskDialog" runat="server" Behavior="None"  
                        Behaviors="None" Height="150px" 
                        Width="300px" InitialBehavior="Pin" InitialBehaviors="Pin"  
                        KeepInScreenBounds="True" Left="" Modal="True" NavigateUrl=""  
                        ReloadOnShow="True" style="display:none;" Title="Validar Tarefa" Top=""  
                        VisibleStatusbar="False" ShowContentDuringLoad="False" Skin="Vista"
                    </telerik:RadWindow> 
                    <telerik:RadWindow ID="ViewTaskNotesDialog" runat="server" Behavior="None"  
                        Height="400px" 
                        Width="400px" 
                        Behaviors="None" InitialBehavior="Pin" InitialBehaviors="Pin"  
                        KeepInScreenBounds="False" Left="" Modal="True" NavigateUrl=""  
                        ReloadOnShow="True" ShowContentDuringLoad="False" VisibleStatusbar="False"  
                        Skin="Vista"  
                        style="display:none;" Title="Notas sobre Tarefa" Top=""
                    </telerik:RadWindow> 
                    <telerik:RadWindow ID="DeleteTaskDialog" runat="server" Behavior="None"  
                        Title="Apagar Tarefa" 
                        Behaviors="None" InitialBehavior="Pin" InitialBehaviors="Pin"  
                        Height="150px" Width="300px" 
                        KeepInScreenBounds="True" Left="" Modal="True" NavigateUrl=""  
                        ReloadOnShow="True" VisibleStatusbar="False"  
                        ShowContentDuringLoad="False" Top="" Skin="Vista"
                    </telerik:RadWindow> 
                    <telerik:RadWindow ID="ViewTaskHistoryWindow" runat="server" Behavior="None"  
                        Height="550px" 
                        Width="1150px" 
                        Behaviors="None" InitialBehavior="Pin" InitialBehaviors="Pin"  
                        KeepInScreenBounds="True" Left="" Modal="True" NavigateUrl=""  
                        ReloadOnShow="True" ShowContentDuringLoad="False" style="display:none;"  
                        Title="HistĂłrico de Tarefas" Top="" VisibleStatusbar="False"
                    </telerik:RadWindow> 
                </Windows> 
            </telerik:RadWindowManager> 

Example Window JavaScript:
<script type="text/javascript">  
            function CloseAndRebind(args) {  
                GetRadWindow().Close();  
                GetRadWindow().BrowserWindow.refreshGrid(args);  
            }  
  
            function GetRadWindow() {  
                var oWindow = null;  
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog  
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)  
  
                return oWindow;  
            }  
  
            function CancelEdit() {  
                GetRadWindow().Close();  
            }  
             
             
        </script> 

Code executed on clicking a cancel button:
protected void LnkCancelChanges_Click(object sender, EventArgs e) 
    { 
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CancelEdit();"true); 
    } 

Code executed on clicking "accept" button:
protected void LnkAcceptChanges_Click(object sender, EventArgs e) 
    { 
        int result = SqlDataSourceEdit.Update(); 
 
        ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true); 
    } 

JavaScript refresh grid function on content page:
function refreshGrid(arg) {  
                        $find("<%= RadAjaxManager.GetCurrent(this).ClientID %>").ajaxRequest("Rebind");  
                    }  

Ajax request code on content page:
protected void RadAjaxManagerProxy1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
    { 
        RadGrid grid = (RadGrid)LoginView1.FindControl("RadMultiPageMain").FindControl("PageViewTarefas").FindControl("RadGridTarefas"); 
        if (e.Argument == "Rebind"
        { 
            grid.MasterTableView.SortExpressions.Clear(); 
            grid.MasterTableView.GroupByExpressions.Clear(); 
            grid.Rebind(); 
        } 
        else if (e.Argument == "RebindAndNavigate"
        { 
            grid.MasterTableView.SortExpressions.Clear(); 
            grid.MasterTableView.GroupByExpressions.Clear(); 
            grid.MasterTableView.CurrentPageIndex = grid.MasterTableView.PageCount - 1; 
            grid.Rebind(); 
        } 
    } 

Any Ideias?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Marco
Top achievements
Rank 1
answered on 11 Mar 2009, 12:48 PM
I've noticed that if I refresh the browser, the window settings I specified are applied again. Could this be an ajaxmanagerproxy issue?
0
Marco
Top achievements
Rank 1
answered on 11 Mar 2009, 02:22 PM
I believe I've found a temporary solution. On the content page (code-behind), where I initiate a rebind of my grid via the ajax request, if I manually respecify all my parameters they will take effect on subsequent window loads. But I'm still in the dark on why the manager and window settings are defaulted/lost. Any ideas?


Thanks in advance.
0
Georgi Tunev
Telerik team
answered on 12 Mar 2009, 02:30 PM
Hi Marco,

The code that you posted looks fine and at this point we cannot tell what the reason for the problem might be. If you manage to isolate the problem in a small sample project, please send it to us and we will check it.

Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Marco
Top achievements
Rank 1
Answers by
Marco
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or