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

[Solved] Updating Grid after window close

3 Answers 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jimmy Stuart
Top achievements
Rank 1
Jimmy Stuart asked on 03 Mar 2008, 11:25 AM

I've got a Window as an Editor for a RadGrid and I'm converting it from the regular controls to the Prometheus versions.  Everything works ok except the grid doesn't refresh itself after the window closes.  I've got the following code:

Main Page:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script type="text/javascript">  
            function ShowEditForm(id, rowIndex)  
            {  
                var grid = $find("<%= ScheduleEditRadGrid.ClientID %>");  
                  
                var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();                  
                grid.get_masterTableView().selectItem(rowControl, true);  
                              
                window.radopen("assignments_edit.aspx?sid=" + id, "EditAssignmentsDialog");  
                return false;   
            }  
             
            function refreshGrid(arg)  
            {  
                if(!arg)  
                {  
                  $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");  
                }  
                else  
                {  
                  $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");  
                }  
            }  
        </script> 
    </telerik:RadCodeBlock> 

and in the Window Page:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script type="text/javascript">  
                function CloseAndRebind()  
                {  
                    GetRadWindow().close();  
                    GetRadWindow().BrowserWindow.refreshGrid(null);  
                }  
                  
                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> 
    </telerik:RadCodeBlock> 

Can you tell me what I haven't changed yet?

Also on a side note your example for this - http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx doesn't post the window page code for some reason.  It also references the KB for the regular controls in the Description for Edit/Update and on that same line tells you to set EnableAJAX to True on the grid, except we know that property was removed.  The part of the Description for Insert gets it correct. You guys might want to update that so folks trying it for the first time don't get confused.

Thanks,

Jimmy

3 Answers, 1 is accepted

Sort by
0
Stuart Dahlenburg
Top achievements
Rank 1
answered on 03 Mar 2008, 11:45 PM
I am experiencing the same issue. The RaisePostBackEvent event is called and the grid rebound however the html of the grid does not refresh.

To get around this I have forced a postback by capturing the OnRequestStart event of the RadAjaxManager. This would indicate to me that there is a problem with the ajax refresh of the grid control.

function OnRequestStart(sender, args)

{

if (args.EventTarget.indexOf("RadAjaxManager1") > -1 || args.EventArgument.indexOf("Rebind") > -1) {

args.set_enableAjax(

false);

}

}



0
Jimmy Stuart
Top achievements
Rank 1
answered on 05 Mar 2008, 05:26 AM
Ok I figured out the problem I was having.  I had set the AjaxSettings to update the Grid and have that update triggered by the Grid.  In the demo for using the Window editors the AjaxSettings they use update the Grid, but it is triggered by the Ajax manager itself.  So by having both settings in the Ajax Manager (Grid triggers Grid and Manager triggers Grid) it all works.
0
Accepted
Stuart Dahlenburg
Top achievements
Rank 1
answered on 05 Mar 2008, 05:54 AM
Thanks that worked.

I had tried linking the RadWindowManger and the grid. Didn't think of linking the AjaxManager and the grid.

Tags
Grid
Asked by
Jimmy Stuart
Top achievements
Rank 1
Answers by
Stuart Dahlenburg
Top achievements
Rank 1
Jimmy Stuart
Top achievements
Rank 1
Share this question
or