RadGrid inside RadXmlHttpPanel showing error

2 posts, 0 answers
  1. Jikesh
    Jikesh avatar
    1 posts
    Member since:
    Dec 2011

    Posted 14 Dec 2011 Link to this post

    Hi 

    i created a page similiar to the demo in http://demos.telerik.com/aspnet-ajax/xmlhttppanel/examples/clientsidecontentload/defaultcs.aspx

    made a few changes in that 

    1. replaced the  asp:Repeater  with a radgrid with the same properties as the radgrid1 in the demo 
    2. added an event RadGrid2_NeedDataSource for the radgrid2 
    3. added a textbox in the page and stored the value got from XmlHttpPanel_ServiceRequest in the page.
    4. the second grid has a pagesize of 10. 

    it works without any problem if the 2nd grid has less than 10 records or if the paging is set to false. but if the paging is set to true and if the record count is more than 10(the pagesize) , it shows the following error

    eScript control 'PageSizeComboBox' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
    Parameter name: scriptControl


    this is my code

    MessagesTelerik.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="MessagesTelerik.aspx.cs" Inherits="MessagesTelerik" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
     
    <head id="Head1" runat="server">
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
     
            <script type="text/javascript">
                function rowSelected(sender, args) {
                    var key = args.getDataKeyValue("JobId");
                    var panel = $find("<%=RadXmlHttpPanel1.ClientID %>");
                    panel.set_value(key);
                }
            </script>
     
        </telerik:RadScriptBlock>
        <style type="text/css">
            .divContainer
            {
                background: url('main_back.png') no-repeat;
                width: 100%;
                height: 400px;
                position: relative;
            }
            .divGrid, .divXmlHttpPanel
            {
                position: absolute;
                top: 86px;
            }
            .divXmlHttpPanel
            {
                top: 132px;
                left: 390px;
            }
            .rgInfoPart
            {
                display: none !important;
            }
            .title
            {
                font-size: 12px;
                color: #606060;
            }
            .info
            {
                color: black;
                font-size: 12px;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="Form2" method="post" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Hay">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" Skin="Hay">
        </telerik:RadAjaxLoadingPanel>
        <div class="divContainer">
            <div class="divGrid">
                <telerik:RadGrid ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
                    Width="370px" AllowSorting="True" PageSize="10" AllowPaging="True" runat="server"
                    AutoGenerateColumns="false" GridLines="None">
                    <MasterTableView ClientDataKeyNames="JobId" Width="100%" Summary="RadGrid table">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Id"  DataField="JobId">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Name" DataField="JobName" UniqueName="Name">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                    <PagerStyle Mode="Slider" PageButtonCount="5" />
                    <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" ClientEvents-OnRowSelected="rowSelected">
                    </ClientSettings>
                </telerik:RadGrid>
            </div>
            <div class="divXmlHttpPanel">
                <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server" Value="FRANR" OnServiceRequest="XmlHttpPanel_ServiceRequest"
                    RenderMode="Block">              
                <telerik:RadGrid ID="RadGrid2"  Width="370px" AllowSorting="True" PageSize="10"
                    AllowPaging="true" runat="server" 
                    OnNeedDataSource="RadGrid2_NeedDataSource"
                    AutoGenerateColumns="false" GridLines="None">
                    <MasterTableView ClientDataKeyNames="JQ_ID" Width="100%" Summary="RadGrid2 table">
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Id"  DataField="JQ_ID" UniqueName="JQ_ID">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Run time" DataField="JQ_RunTime" UniqueName="Runtime">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Duration" DataField="JQ_Duration" UniqueName="Duration">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Total messages" DataField="totOutput" UniqueName="Totalmessages">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                    <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" >
                    </ClientSettings>
                </telerik:RadGrid>
                <asp:TextBox ID="txtJobId" style="visibility:hidden;" runat="server"></asp:TextBox>
                </telerik:RadXmlHttpPanel>
            </div>
        </div>
        </form>
    </body>
    </html>

    MessagesTelerik.aspx.cs

    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.UI.WebControls;
     
    using Telerik.Web.UI;
     
    public partial class MessagesTelerik : System.Web.UI.Page
    {
        DateTime dtRunDateStart = DateTime.Now.AddMonths(-3);
        DateTime dtRunTimeEnd=DateTime.Now;
        protected void Page_Load(object sender, EventArgs e)
        {
             
        }
        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            RadGrid1.DataSource = getDataTable(dtRunDateStart, dtRunTimeEnd);
        }
     
        protected void RadGrid2_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            string val = txtJobId.Text;
            RadGrid2.DataSource = getDataTable2(val,dtRunDateStart, dtRunTimeEnd);
        }
     
        public DataTable getDataTable(DateTime dtRunDateStart, DateTime dtRunTimeEnd)
        {
     
            string strQuery = @"select * from messages
                                    where JQ_RunTime between'" + dtRunDateStart.ToString("yyyy-MM-dd") + "' and '" + dtRunTimeEnd.ToString("yyyy-MM-dd") + "'";
     
     
            DataTable dtQuery = DB.GetDataTable(strQuery);
     
     
            return dtQuery;
        }
     
        protected void XmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)
        {
            string val = e.Value;
            txtJobId.Text = val;
            System.Data.DataTable table = getDataTable2(val, dtRunDateStart, dtRunTimeEnd);
     
            RadGrid2.DataSource = table;
            RadGrid2.DataBind();
        }
     
        private DataTable getDataTable2(string jobid, DateTime dtRunDateStart, DateTime dtRunTimeEnd)
        {
             
            string strQuery = @"select * from messages2 where
                                    JQ_RunTime between'" + dtRunDateStart.ToString("yyyy-MM-dd") + "' and '" + dtRunTimeEnd.ToString("yyyy-MM-dd") + "'";
     
            DataTable dtQuery = DB.GetDataTable(strQuery);
     
            return dtQuery;
        }
    }


    pls let me know what i missed to add



  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 19 Dec 2011 Link to this post

    Hi Jikesh,

    This is a known issue of the XmlHttpPanel, when the Grid is using advanced paging. The complexity of the RadGrid does not allow to make it work correctly in all scenarios with the RadXmlHttpPanel. Basically when the Mode of the PagerStyle is set to one of the values - Slider, Advanced, NextPrevAndNumeric, NextPrevNumericAndAdvanced - the Grid will not work as expected. That's why we are using NumericPages in the "Grid in XmlHttpPanel Demo".

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