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

RadGrid inside scheduler advanced edit/insert form

10 Answers 331 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Radoslaw
Top achievements
Rank 1
Radoslaw asked on 19 Feb 2008, 08:45 PM
hi!

I have rad grid inside the scheduler advanced edit/insert form. I declared an event on row clicked for grid but i receive javascript error ( it can not find the function).

Thanks for help
Radek

10 Answers, 1 is accepted

Sort by
0
Accepted
T. Tsonev
Telerik team
answered on 22 Feb 2008, 12:13 PM
Hello Radoslaw,

We were unable to reproduce the issue locally. I am attaching a sample project that we have used for testing. It shows no JavaScript errors.

Can you give us more details about your scenario? The template definition will help us to determine the problem.

Regards,
Tsvetomir Tsonev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Radoslaw
Top achievements
Rank 1
answered on 09 Mar 2008, 10:57 PM
Hi!

I'm sorry it took so long to replay, but i had accident.

In my scenario i had rad grid from asp radcontrols v. 5.0 or 5.1 (not prometheus). It was inside multipage control.
After i replaced it with prometheus version, problem disappeared.

Thanks for help and once again sorry!

Radek
0
Murad Ajani
Top achievements
Rank 1
answered on 13 Aug 2008, 06:10 PM
Could you please email me the sample project as well.
Thanks
0
Accepted
T. Tsonev
Telerik team
answered on 14 Aug 2008, 07:02 AM
Hello Murad,

I am attaching you the sample project. It demonstrates how to host a RadGrid into the advanced form. You should also take a look at the advanced form customization documentation and example:

Kind regards,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Francesco
Top achievements
Rank 1
answered on 27 Jul 2011, 05:06 PM
Hello,

I examined your attached project and since I'm having problems in a context similar to this (integrating a RadGrid in RadScheduler), I will explain it here.

Unlike this sample project, in which the advanced insert form template is defined inside the RadScheduler tag, I followed the advanced form customization guide (because my advanced form is more complex). I defined a custom user control in which there is a RadTabStrip with 3 tabs and inside one of them I integrated a RadGrid, with paging, sorting and filtering. The RadScheduler is defined in a user control that is the content of a masterpage, and it's ajaxified using RadAjaxManager (declared into masterpage but set using the Proxy inside the usercontrol). It is databound to a collection filled from a database, as well as the the DataTable bound to RadGrid.

Here is some excerpt from Master and content page to show Ajax, ScriptManager and RadScheduler settings:

Masterpage:
...
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager2" runat="server">
        <Scripts>
            <asp:ScriptReference Path="AdvancedForm.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager>
    ...
    <asp:ContentPlaceHolder ID="PlaceHolder" runat="server" />
    ...
    </form>
</body>

Content page:
...
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolder" runat="server">
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    ....
   <telerik:RadScheduler ID="RadScheduler1" runat="server" ... >
                <AdvancedForm Modal="true" />
                <AppointmentTemplate>
                    ...
                </AppointmentTemplate>
                <InlineInsertTemplate>
                    <scheduler:InlineInsertForm runat="server" ID="InlineInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>'... />
                </InlineInsertTemplate>
                <AdvancedInsertTemplate>
                    <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>' ...  />
                </AdvancedInsertTemplate>
                <AdvancedForm EnableCustomAttributeEditing="True" />
                <AdvancedEditTemplate>
                    <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>' ...  />
                </AdvancedEditTemplate>
   </telerik:RadScheduler>
</asp:Content>


Since every action which triggers a postback (in this case, sorting, changing page and filtering) causes the loss of the state of the advanced form (every field becomes empty), I wrapped the RadGrid in a RadAjaxPanel. Now any of that action gives me the javascript error "Script control 'rfltMenu' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors()." and if I remove filtering support, it gives me the same error on another grid component and so on.

I read that the RegisterWithScriptManager attribute was introduced to handle these errors, I've set it to false and called the RegisterScriptControl() passing the RadGrid instance in the OnPreRender method of the AdvancedForm usercontrol, but to no avail.

Here is some excerpt from the usercontrol:

Excerpt from AdvancedForm.aspx:
<telerik:RadAjaxPanel ID="contactsRefreshPanel" runat="server">
    <telerik:RadGrid AutoGenerateColumns="false" ID="ContactsGrid"
        OnNeedDataSource="ContactsGrid_NeedDataSource"
        AllowSorting="True" AllowFilteringByColumn="true"
        AllowPaging="True" PageSize="2"
        RegisterWithScriptManager="false"
        runat="server">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView AutoGenerateColumns="false" TableLayout="Auto">
            <Columns>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Nome" SortExpression="Name"
                    UniqueName="Name" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Surname" HeaderText="Cognome" SortExpression="Surname"
                    UniqueName="Surname" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Company" HeaderText="Azienda" SortExpression="Company"
                    UniqueName="Company" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Email" HeaderText="Email" SortExpression="Email"
                    UniqueName="Email" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CellularPhone" HeaderText="Cellulare" SortExpression="CellularPhone"
                    UniqueName="CellularPhone" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>

Excerpt from AdvancedForm.cs:
public partial class AdvancedForm : System.Web.UI.UserControl
    {
        ...
        protected void Page_Load(object sender, EventArgs e)
        {
            UpdateButton.ValidationGroup = Owner.ValidationGroup;
            UpdateButton.CommandName = Mode == AdvancedFormMode.Edit ? "Update" : "Insert";
 
            InitializeStrings();
            InitializeRecurrenceEditor();
           
            // A series of client scripts registered
             
        }
        ...
        protected void ContactsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            ContactsGrid.DataSource = Default.GetDataTable("SELECT * FROM Contacts");
        }
        ...
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
 
            if (!FormInitialized)
            {
                FormInitialized = true;
            }
 
            if (!this.DesignMode)
            {
                // Test for ScriptManager and register if it exists
                ScriptManager sm = ScriptManager.GetCurrent(Page);
 
                if (sm == null)
                    throw new HttpException("A ScriptManager control must exist on the current page.");
 
                sm.RegisterScriptControl(ContactsGrid);
            }
        }
        ...
    }

Perhaps there something in the Ajax settings which isn't correct? I tried many things, including using RadAjaxManagerProxy to ajaxify the grid only but without results.
Any other suggestion is welcome. I'm stuck on this problem for 2 days.

By the way, I'm using RadControls Q1 2011 SP2.

Thanks in advance!
0
Francesco
Top achievements
Rank 1
answered on 28 Jul 2011, 04:33 PM
No one has any advice on what could be the cause of the error, or something to try to find it out?
I'm stuck here and I need to deliver this part of the software next week, so I'm a little strict on time...

Thank you!
0
Dan Lehmann
Top achievements
Rank 1
answered on 28 Jul 2011, 11:15 PM
Hi Francesco,
As opposed to the RadAjaxLoadingPanel, have you tried just wiring up the controls like this:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" >
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
                <telerik:AjaxUpdatedControl ControlID="contactsRefreshPanel" />
                <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="RadScheduler1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                <telerik:AjaxUpdatedControl ControlID="contactsRefreshPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="contactsRefreshPanel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                <telerik:AjaxUpdatedControl ControlID="contactsRefreshPanel" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

0
Francesco
Top achievements
Rank 1
answered on 29 Jul 2011, 09:40 AM
Hello Dan,
thank you for having replied and for your suggestion.
Do you mean using RadAjaxManager settings instead of wrapping the grid in RadAjaxPanel (not RadAjaxLoadingPanel), right?
I tried your solution, replacing RadAjaxPanel with an asp:Panel and defining settings in the right place using RadAjaxManagerProxy (because of element scopes), in this way:

Master page:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" />

Content page:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" />
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

AdvancedForm usercontrol:

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy2" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ContactsGridPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ContactsGridPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ContactsGridPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadScheduler1" />
                    <telerik:AjaxUpdatedControl ControlID="ContactsGridPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

Unfortunately, I'm still getting the same javascript error on every action on the grid (with and without EnableAjax="true" set on RadAjaxManager).

This error comes either with RegisterWithScriptManager="false" and the RegisterScriptControl(ContactsGrid) call in the PreRender phase (as in the previous post) or without it.
However, reported errors (with the same grid setting) are slightly different in the two scenarios: in the first case the reported unregistered script control is 'rfltMenu', in the other case is 'PageSizeComboBox', both controls generated by RadGrid, I guess.

Any other indication is welcome.
Thanks!
0
Francesco
Top achievements
Rank 1
answered on 29 Jul 2011, 11:20 AM
I also placed the RadGrid outside RadPageView (RadMultiPage), just for test, mantaining that Ajax settings.
The js error triggers on the same actions, but is different: "Please, see whether wrapping the code block, generating the exception, within RadCodeBlock resolves the error.". Examining the stacktrace, I found this detail: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).".
I wrapped in RadCodeBlock or RadScriptBlock every script which contained code blocks (very few), in every scope, from Masterpage to usercontrols, no script is present in the head tag, and the error keeps showing up.
0
Peter
Telerik team
answered on 02 Aug 2011, 10:29 AM
Hello Francesco,

We have replied in the other forum thread about this issue -
http://www.telerik.com/community/forums/aspnet-ajax/scheduler/script-control-radajaxmanager1-is-not-a-registered-script-control.aspx#1744753

Kind regards, Peter
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Scheduler
Asked by
Radoslaw
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Radoslaw
Top achievements
Rank 1
Murad Ajani
Top achievements
Rank 1
Francesco
Top achievements
Rank 1
Dan Lehmann
Top achievements
Rank 1
Peter
Telerik team
Share this question
or