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

[Solved] Javascript binding from popup

2 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Yves
Top achievements
Rank 1
Yves asked on 24 Nov 2010, 04:14 PM
Hello,

I'm trying to bind a grid using a controller method called from a popup window.

I use javascript in my popup window  to find the grid on the parent window, to call the method controller and to bind the grid :

<script type="text/javascript">
          
        function BindToParentWindow() {
            var parentGrid = window.opener.$('#TestUsersGrid').data('tGrid');
              
            $.ajax(
            {
                type: "POST",
                url: "/Home/BindToParentWindow",
                async: false,
                dataType: "json",
                success: function (data) {
                    parentGrid.dataBind(data);
                }
            });
  
            window.close();
        }
    </script>

When I launch the javascript function above, I get an error message from visual studio  : "Jscript object expected" in the file  telerik.grid.js.
If I click the "Ignore" button,  the datas are correctly bound to the grid.

I have attached  a test project wich shows the problem. 

Regards,


 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 24 Nov 2010, 04:50 PM
Hello ybernicot,

 This seems to be one of those IE quirks as your code works perfectly in other browsers. After lots of debugging I found out that this code:

Array.prototype.push.apply(this.data, data);

and the fact that "data" is created in a popup window (a different DOM document)  is causing the problem. 

The only workaround I can suggest is to make the 'data' array suitable for the parent window like this:

function BindToParentWindow() {
    var parentGrid = window.opener.$('#TestUsersGrid').data('tGrid');
    $.ajax({
        type: "POST",
        url: "/Home/BindToParentWindow",
        async: false,
        dataType: "json",
        success: function (data) {
            parentGrid.dataBind(window.opener.$.makeArray(data));
        }
    });
 
    window.close();
}

Best wishes,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Yves
Top achievements
Rank 1
answered on 24 Nov 2010, 05:03 PM
Hello Atanas,

It works fine with your workaround.
Thanks for your help.
Tags
Grid
Asked by
Yves
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Yves
Top achievements
Rank 1
Share this question
or