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

RadWindow broken in 1001

6 Answers 204 Views
Window
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 06 Oct 2008, 01:45 AM
Hi

My RadWindow code worked in 826 but not in 1001.

I am returning a value from a radwindow to refresh a RadGrid.

Here is the page code:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
    <script type="text/javascript"
        function ShowEditForm(id, rowIndex) { 
            var grid = $find("<%= gvwTransactions.ClientID %>"); 
 
            var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element(); 
            grid.get_masterTableView().selectItem(rowControl, true); 
 
            window.radopen("transaction-details.aspx?TransactionId=" + id, "TransactionListDialog"); 
            return false; 
        } 
        function ShowInsertForm(id, node) { 
            window.radopen("transaction-details.aspx?ItemId=" + id + "&SelNode=" + node, "TransactionListDialog"); 
            return false; 
        } 
        function ShowMoveForm(id, node) { 
            window.radopen("move-stock.aspx?ItemId=" + id + "&SelNode=" + node, "TransactionListDialog"); 
            return false; 
        } 
        function ShowTransferForm(id, node) { 
            window.radopen("transfer-split.aspx?ItemId=" + id + "&SelNode=" + node, "TransactionListDialog"); 
            return false; 
        } 
        function refreshGrid(arg) { 
            switch (arg) { 
                case 'Rebind': 
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind"); 
                    break; 
                case 'RebindAlsoTable': 
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAlsoTable"); 
                    break; 
                case 'RebindAndNavigate': 
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate"); 
                    break; 
                case 'RebindAndNavigateAlsoTable': 
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigateAlsoTable"); 
                    break; 
                default: 
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigateAlsoTable"); 
            } 
        } 
    </script> 
</telerik:RadCodeBlock> 


And here is the code in the radwindow

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
    <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> 
    </telerik:RadCodeBlock> 

Any idea why the closeandrebind event does not work?

It says GetRadWindow is not defined.

Thanks

6 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 06 Oct 2008, 07:26 AM
Hi Michael,

Could you please send me a small sample project where this problem can be reproduced? I am asking you this because the GetRadWindow() function is not changed in the latest release and the code is working fine - you can check it in our Returning Values from a Dialog demo.



All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Vincent Russell
Top achievements
Rank 1
answered on 06 Oct 2008, 02:57 PM

Hi,

I can corroborate this behaviour.  I use the same code as Michael and get "BrowserWindow is null or not an object" when running the CloseAndRebind function.

When I roll back to version 826 it works with no errors.

I was beginning to think there was something I was missing in my code until I saw Michael's post.  So thanks for pointing me in the right direction!

V.

0
Marco Piumi
Top achievements
Rank 2
answered on 06 Oct 2008, 08:28 PM
I have also this problem, with the previous version It worked  and now no more.

It's a problem, since I must deliver the product in next days.

I thought graves a my error, even if knew that before it worked.

Thanks to Michael for the post.
At least I do not lose other time

0
Georgi Tunev
Telerik team
answered on 07 Oct 2008, 12:49 PM
Guys,

I just checked this scenario and everything is working on my side. The exact same logic is used in the Window Editing demo and it is working there as expected as well.

Please send us a sample project in a support ticket and we will check it right away - if there is any problem, we will do our best to provide you with a solution right away.


Greetings,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Marco Piumi
Top achievements
Rank 2
answered on 07 Oct 2008, 03:46 PM
I resolved the problem  !!!

The cause of the problem was object returned by RadWindow() after windows is closed : this object was null.

 

Parking the object returned by RadWindows() in a variable, after window closing, the variable is not null and it worked fine !

I confirm that previous version worked, while the new version don't work with the code of your example.


 
function GetRadWindow() {  
    var oWindow = null;  
    if (window.radWindow) oWindow = window.radWindow;  
    else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
    return oWindow;  
}  
 
function Close() {  
    var hidden = document.getElementById("hidden_CodiceCommessa").value;  
    
    var win = GetRadWindow
();  
    if (hidden == "")  
        win.Close();  
    else {  
        win.Close(hidden);  
        win.BrowserWindow.SubmitPage();  
    }  
}  
 

I hope of being be clear.
0
Georgi Tunev
Telerik team
answered on 08 Oct 2008, 03:33 PM
Hi guys,

Thanks to Michael that sent us a reproduction code, we managed to find the reason for the problem. For convenience I am pasting my reply to him below:

Hello Michael,

Thank you very much for the code - it helped us find the problem. In your code you have set DestroyOnClose to true (this property is set to false in the Window Editing demo and that is why there the problem does not exist). When DestroyOnClose is set to true, RadWindow's object will be destroyed once the window is closed. The code in the content page however states:
GetRadWindow().Close();
GetRadWindow().BrowserWindow.refreshGrid(args);


What happens is that the first line is executed and the window is closed. When the second line of code takes action however, RadWindow does not exist anymore, hence the error. To fix it, you simply need to switch the 2 lines:
GetRadWindow().BrowserWindow.refreshGrid(args);
GetRadWindow().Close();


e.g. to update the grid first and then to close the window.


On a side note, I strongly recommend to check your client code and to edit it so it match the naming convention of the new framework.
Note that currently RadWindow supports both naming conventions for backward compatibility, however at some point in the future when the migration is over, we might remove the old methods and your code will not work.


All the best,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Michael
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Vincent Russell
Top achievements
Rank 1
Marco Piumi
Top achievements
Rank 2
Share this question
or