Use 2 grids on same page with RadAjaxManagerProxy and RasAjaxManager

4 posts, 0 answers
  1. RB
    RB avatar
    126 posts
    Member since:
    Dec 2013

    Posted 23 Jul 2014 Link to this post

    I have a User Control MainPage.aspx. Based on the tab clicked, it adds another control Page1.cs.Based on WorkFlow state, this adds another control Page2.cs.    Page2 has 5 controls out of which 2 are radgrids. Page 2 has an Update panel, where all the 5 controls are added. Since this is the page with the 2 radgrids which need to be ajaxified, I have added a RadAjaxManager here:
    protected override void OnPreRender(EventArgs e)
     {
         base.OnPreRender(e);
         RadAjaxManager manager = new RadAjaxManager();
         manager = RadAjaxManager.GetCurrent(Page);
         manager.ID = "RadAjaxManager1";
         manager.AjaxSettings.AddAjaxSetting(_RadGridCtrl1, _UpdatePanel);
         manager.AjaxSettings.AddAjaxSetting(_RadGridCtrl2, _UpdatePanel);    
     
     }

    Now Page2 to add the 1st grid, calls another class Inner1.cs, which based on certain conditions, calls Inner2 whcih again calls Inner3.cs which has the RadGrid. Here the RadGrid is simply added as   this.Controls.Add(this._RadGrid1); No panels or update Panels here.  Inner2 adds Inner3 in a Panel. I have added the RadAjaxManagerProxy to Inner1 as follows:
    protected override void OnPreRender(EventArgs e
    {    
       base.OnPreRender(e);         
       radProxy.ID = "RadAjaxManagerProxy2";
       radProxy.AjaxSettings.AddAjaxSetting(this._Inner2, _FsMain);
     }

    A similar approach to add the second radGrid in the page is used. Page2.cs invokes Inner11.cs and adds it in an Update Panel. Inner11.cs has the AjaxManagerProxy as follows:
    protected override void OnPreRender(EventArgs e)
     
          base.OnPreRender(e);
               
          radProxy.ID = "RadAjaxManagerProxy1";           
          radProxy.AjaxSettings.AddAjaxSetting(this._Inner22, _FsMain);
      }
    Inner22.cs has the RadGrid. No panel or Update Panel here also.
    These grids only allow delete, refresh and sort. Delete works good. But Refresh and Sort do not work.Both of them give the javascript error: Uncaught TypeError: Cannot set property 'control' of undefined.

    Earlier, without the RadAjaxManagerProxy, I had both the grids with their own RadAjaxManager. Refresh worked but sort did not work. It would sort a column one way but on 2nd click sort the next column! Hence after research I used the proxy which seems the right approach but not working for me!

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Jul 2014 Link to this post

    Hello,

    Based on the description it seems that the RadGrid controls are placed inside an UpdatePanel and also added to the RadAjaxManager settings. Please note that if a control is Ajax-ified by both RadAjaxManager and UpdatePanel, this could lead to unexpected behavior.

    It is recommended to use consistent method for Ajax-enabling the controls on the page. The RadAjaxManager provides a lot of flexibility and could easily replace the UpdatePanels. If you would like to Ajax-ify multiple controls you could wrap them in a regular Panel control and add the Panel to the AjaxSettings.

    If you would like additional information on the RadAjaxManager and different scenarios it could be used in you would find the following articles interesting:


    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RB
    RB avatar
    126 posts
    Member since:
    Dec 2013

    Posted 28 Jul 2014 in reply to Viktor Tachev Link to this post

    I removed the Update Panels and the problem still persists!
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 30 Jul 2014 Link to this post

    Hi,

    You could try couple of things that could point to the reasons that cause the problematic behavior.

    Disable Ajax in the project by removing all UpdatePanels, RadAjaxPanels and setting the EnableAjax property of RadAjaxManager to false. If after this the issue persists - the cause is most likely not Ajax related.

    In case the issue is observed only when Ajax is enabled, please make sure that when you add Ajax settings programmatically, you follow the approach described in the Add AjaxSettings Programmatically article. Ensure that the Page_Load event is used to add the settings.

    Moreover, have in mind that only one RadAjaxManager could be used on a page. It is recommended to place the control on the page that is highest in the hierarchy, for example - a MasterPage. After this you could get reference to the RadAjaxManager using the GetCurrent() method. Using the GetCurrent() method is illustrated in this article.


    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top