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

Problem when updating RadGrid with outside dropdown using RadAjaxManager

4 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
psiegers45
Top achievements
Rank 1
psiegers45 asked on 03 May 2010, 07:33 PM
Hi, I need help for the following problem.

Scenario:
I am trying to update RadGrid with outside dropdown using RadAjaxManager. I need to do this only when the RadGrid is actually included on the page and when the FormTemplate is shown. This "included or not" is determined by page code behind (on the form that contains the grid) using TDs and making them visible or not, which depends on what's selected on the form by the user.

The control where it all is declared is attached (ascx and ascx.cs). This control is loaded dynamically with other controls in one single page. Trying the RadAjaxManager like attached, it gives me the following error:

Microsoft JScript runtime error: Sys.InvalidOperationException: Could not find UpdatePanel with ID 'ctl00_ctl08_ctl00_ctl08_RadGrid1Panel'. If it is being updated dynamically then it must be inside another UpdatePanel.

I suppose this is because the RadGrid is not present yet on the form.
So how can I update the RadGrid from the outer form only when it is present?

Sorry for not attaching classes because they are rather long, but at least here's the xxx declaration:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
   <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ddlMotivoGasto">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ddlMotivoGasto" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>

If you need any more code I'll be happy to provide.

Thanks in advance for your kind help.
Regards, Pieter

4 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 03 May 2010, 07:38 PM
Is the grid inside of a user control or is both the drop-down list and the grid inside of the user control?
0
psiegers45
Top achievements
Rank 1
answered on 03 May 2010, 09:41 PM
Hi, yes both controls are part of the same usercontrol. 

I have seen this example but that already has the grid present:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridcomboajax/defaultcs.aspx?product=grid

Actually, when the edit form template is loaded I'm able to get to the controls on the server using ItemCreated using code like this:

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditFormInsertItem && e.Item.IsInEditMode)
            {
                if (e.Item.OwnerTableView.IsItemInserted)
                {
                    GridEditFormItem editFormItem = (GridEditFormItem)(RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[0]);
                    HyperLink objLnkFechaSalidaRG = (HyperLink)editFormItem.FindControl("lnkFechaSalidaRG");
                    TextBox objTxtFechaSalidaRG = (TextBox)editFormItem.FindControl("txtFechaSalidaRG");
                    if (objLnkFechaSalidaRG != null &&
                        objTxtFechaSalidaRG != null)
                        objLnkFechaSalidaRG.NavigateUrl = "javascript:show_calendar('Form1." + objTxtFechaSalidaRG.ClientID + "','','',dattePatternn,localleLangguage);";
                    // etc.

So from within the grid it works practically quite nice already.

To repeat, what I need is (when the grid and edit form template is loaded) be able to make callbacks on the grid to change its control aspects of that template. Some controls need to appear, some not, depending on user actions.

So how does one accomplish that??
If you can point to any sample that does that it would be great.

Thanks, Pieter
0
psiegers45
Top achievements
Rank 1
answered on 03 May 2010, 11:35 PM
Hi again, I just managed to get an opening to continue my approach, first by using visible on the radgrid control instead of it's container, next by ajaxifying every control that is ever updated by controls that also affect the radgrid. Sofar I have now this code:

<telerik:RadAjaxManager
    ID="RadAjaxManager1"
    runat="server"
    EnableAJAX="true"
    DefaultLoadingPanelID="RadAjaxLoadingPanel1">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ddlMotivoGasto">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ddlMotivoGasto" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAvion" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaHotel" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAnticipo" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos1" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos2" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="cbSolicitaAvion">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ddlMotivoGasto" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAvion" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaHotel" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAnticipo" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos1" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos2" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="cbSolicitaHotel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ddlMotivoGasto" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAvion" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaHotel" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAnticipo" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos1" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos2" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="cbSolicitaAnticipo">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                <telerik:AjaxUpdatedControl ControlID="ddlMotivoGasto" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAvion" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaHotel" />
                <telerik:AjaxUpdatedControl ControlID="cbSolicitaAnticipo" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos1" />
                <telerik:AjaxUpdatedControl ControlID="tblCamposDinamicos2" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="ddlTipoViaje">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="txtPoliticasAplicables" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>

With this code, all controls with mentioned IDs are now wrapped inside UpdatePanels which cause the controls to update each other almost instantly and there's no more page refrshing too. Works great sofar.

Hope this helps others too a bit.

Regards, Pieter
0
Christopher
Top achievements
Rank 1
answered on 15 Mar 2012, 06:41 PM
Thanks, I was running into the same problem. I added the parent control of the control I was trying to update to the AjaxSettings update controls collection as suggested below. It seems to have taken care of the problem.
Tags
Grid
Asked by
psiegers45
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
psiegers45
Top achievements
Rank 1
Christopher
Top achievements
Rank 1
Share this question
or