Can't Get Client Side Object

5 posts, 0 answers
  1. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 24 Apr 2013 Link to this post

    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.



  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 25 Apr 2013 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 25 Apr 2013 Link to this post

    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.

  5. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 29 Apr 2013 Link to this post

    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.
  6. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 30 Apr 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017