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

Can't Get Client Side Object

4 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 2
Danny asked on 24 Apr 2013, 02:34 PM
I'm in IE8 and I'm opening a modal dialogue from codebehind, afterwards I'm running a function.

String ScriptInput = String.Format("window.showModalDialog(\"" + NavigateUrl + "\", \"\", \"dialogHeight:500px;dialogWidth:845px;resizable:yes;status:no;unadorned:no;edge:raised\"); RefreshGrid()");  
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "newWindow", ScriptInput, true);

When I have this

function RefreshGrid(){
          alert("The Grid Will Refresh At This Point");
}

The alert pops up as soon as I close the modal dialogue.   Perfect so far.  I have a Radgrid on the parent page:
<telerik:RadGrid ID="rgSupplementalAllocation"

And when I attempt to do this:
function RefreshGrid() {
                var RadGrid = $get("<%= rgSupplementalAllocation.ClientID %>");
                var MasterTableView = RadGrid.get_masterTableView();
                MasterTableView.rebind();
            }

-I get the Microsoft JScript runtime error: Object doesn't support this property or method in reference when I'm calling get_masterTableView from the RadGrid object.

When I try this:
function RefreshGrid() {
                var RadGrid = $find("<%= rgSupplementalAllocation.ClientID %>");
                var MasterTableView = RadGrid.get_masterTableView();
                MasterTableView.rebind();
            

-I get Microsoft JScript runtime error: 'null' is null or not an object in reference to the RadGrid object.

The page uses RadAJAXManager, and I've tried turning it off and on.  I've also looked at the dynamic page and found the div id that the script was parsed to look for as plain as day. 

I merely want to find the RadGrid client object so I can call a rebind.



4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Apr 2013, 11:06 AM
Hello,

If you add below code in your page then you can access this grid client side.

<telerik:RadGrid ID="RadGrid1" runat="server">
..........
..........
</telerik:RadGrid>


Now, If you want to acees MasterTableView on client side then you must have to assign DataSource to RadGrid,

RadGrid1.DataSource = ""; // Your DataSource
RadGrid1.DataBind();


Thanks,
Jayesh Goyani
0
Danny
Top achievements
Rank 2
answered on 25 Apr 2013, 01:24 PM
Jayesh, thanks for the stab, but I posted only an abbrevieated version of the RadGrid so that you could see its ID attribute. 

By way of example I have no problem getting the RadGrid object client side by putting a RadButton on the main page and using an OnClientClicked method.

It is only when I come out of this modal dialogue that I cannot retrieve the RadGrid object client-side.

0
Daniel
Telerik team
answered on 29 Apr 2013, 03:54 PM
Hello Danny,

You could try to rebind the grid on body unload event however I suspect that IE might open a new window (when you close the current one) in this case. I would personally recommend that you stay away from this IE modal dialog as I have seen it behave differently across the popular browsers. You can also examine this blog post. In my opinion RadWindow would be a better way to go in this scenario.

Best regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Danny
Top achievements
Rank 2
answered on 30 Apr 2013, 02:20 PM
Thank you for the information Daniel, the blog you sent me looks very relevant-  and I will attempt your proposed solution.

I suppose I should always mention that my app is (for the time being) IE8 only and that there are several design choices that I have inherited from other developers. 

Yes, RadWindow has, in fact been terrific to use.
Tags
Grid
Asked by
Danny
Top achievements
Rank 2
Answers by
Jayesh Goyani
Top achievements
Rank 2
Danny
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or