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

Grid View Rowselect not working with Ajax

7 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nixon
Top achievements
Rank 1
Nixon asked on 31 Dec 2012, 10:05 PM
Hello,

I have a RadGrid in my User Control component. The display, paging etc everything works fine w/o AJAX. But the moment I introduce AJAX using RadAjaxManager (I haven't tried any other AJAX method!), the grid will still page/sort but I can't do a rowselect after the page/sort. The code is shown below.

Thanks.

  <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="LoadingPanel2">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radGridProviders">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radGridProviders"
                        LoadingPanelID="LoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Skin="Office2007">
    </telerik:RadAjaxLoadingPanel>

        <telerik:RadGrid ID="radGridProviders" runat="server" AllowMultiRowSelection="false" AutoGenerateColumns="False"
                GridLines="Horizontal" EnableViewState="true"
                AllowSorting="true" PageSize="10" AllowPaging="True"
                Width="750"
                OnNeedDataSource="radGridProviders_NeedDataSource" Skin="Vista">
            <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
            <MasterTableView ClientDataKeyNames="ProvKey,FirstName,LastName" AllowNaturalSort="false">
                    <SortExpressions>
                        <telerik:GridSortExpression FieldName="FirstName" SortOrder="Ascending" />
                    </SortExpressions>
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Name" UniqueName="FullName" DataField="FullName"
                            SortExpression="FullName" HeaderButtonType="TextButton">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings EnableRowHoverStyle="true">
                    <Selecting AllowRowSelect="true" />
                    <ClientEvents OnRowSelected="radGrid_RowSelected"/>
                </ClientSettings>
        </telerik:RadGrid>

        protected void Page_Load(object sender, EventArgs e)
        {
            #region InitScripts
            string script = "function InitScripts() {" + Environment.NewLine
                + "  if (!isInit) { " + Environment.NewLine
                + "modalFormUrl = \"" + SPContext.Current.Web.Url + "/Pages/modal_providerdetail.aspx?\";" + Environment.NewLine
                + string.Format("radGridProviders = $find('{0}');", radGridProviders.ClientID) + Environment.NewLine
                + "isInit = true;"
                + "}}";
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "InitScripts", script, true);
            #endregion

        }

        protected void radGridProviders_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            if (Session[SESSION_ProvidersList] != null)
                radGridProviders.DataSource = Session[SESSION_ProvidersList];
            else
                SetDataSource();
        }

        public void SetDataSource()
        {
            Logger.LogDebug("[ResultsUC::SetDataSource()] start", LogCategory.SHREDD);

            List<Provider> providers = null;

           ProviderClient webServiceClient = null;
            try
            {
                webServiceClient = GatewayService.getInstance();
                providers = webServiceClient.GetResultsWithLimit(MAX_PROVIDERS, SearchCriteriaConsumer);
            }
            finally
            {
                if (webServiceClient != null)GatewayService.closeInstance(webServiceClient);
            }

            if (providers != null)
            {
                radGridProviders.DataSource = providers;
                Session[SESSION_ProvidersList] = providers;// Set to Session
            }

        }



7 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 03 Jan 2013, 11:23 AM
Hi Nixon,

Could you please inspect the request when you try to select a row in the RadGrid control and verify of any js errors appear? Also please try wrapping the whole RadGrid into RadAjaxPanel and let me know how it goes.

All the best,
Maria Ilieva
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.
0
MTC
Top achievements
Rank 1
answered on 31 Jan 2013, 01:35 PM
Hi..
I too not able to work with  RadAjaxManager and OnSelectedIndexChanged event of telerik..OnSelectedIndexChanged event i have to select a row and display that row related data..

below is my code.. please help me on this:

<telerik:RadAjaxManager ID="tlkRadAjaxMgr" runat="server" DefaultLoadingPanelID="tlkRadAjaxLoadingPanels">
                        <AjaxSettings>
                            <telerik:AjaxSetting AjaxControlID="rg_ViewTickets" >
                                <UpdatedControls>
                                    <telerik:AjaxUpdatedControl ControlID="rg_ViewTickets"  />
                                </UpdatedControls>
                            </telerik:AjaxSetting>
                        </AjaxSettings>
                    </telerik:RadAjaxManager>
  <telerik:RadAjaxLoadingPanel ID="tlkRadAjaxLoadingPanel" runat="server">
                    </telerik:RadAjaxLoadingPanel>
                    <telerik:RadGrid ID="rg_ViewTickets" runat="server" PageSize="15" AllowPaging="true"
                        AllowCustomPaging="true" ShowStatusBar="true" AllowSorting="true" AutoGenerateColumns="false"
                        Width="100%" OnSelectedIndexChanged="rgViewTickets_SelectedIndexChanged" OnNeedDataSource="rgViewTickets_NeedDataSource"
                        ToolTip="Click here to view details">
                    
                        <MasterTableView Width="100%">
                            <Columns>
                                <telerik:GridDateTimeColumn HeaderText="Created On" DataFormatString="{0:MM/dd/yyyy}"
                                    SortExpression="CreatedOn" DataField="CreatedOn" FilterListOptions="VaryByDataType">
                                </telerik:GridDateTimeColumn>
                                <telerik:GridDateTimeColumn HeaderText="FollowUp Date" DataFormatString="{0:MM/dd/yyyy}"
                                    SortExpression="followUpBy" DataField="followUpBy" FilterListOptions="VaryByDataType">
                                </telerik:GridDateTimeColumn>
                                <telerik:GridTemplateColumn HeaderText="Ticket No" SortExpression="TicketNumber">
                                    <ItemTemplate>
                                        <asp:Label ID="lblTicketNo" runat="server" Text='<%#Eval("TicketNumber") %>'> </asp:Label>
                                        <asp:HiddenField ID="hidId" runat="server" Value='<%#Eval("IncId") %>' />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
  </Columns>
 </MasterTableView>
                         <ClientSettings EnablePostBackOnRowClick="true">
                            <Selecting AllowRowSelect="true" />
                        </ClientSettings>
                        
                    </telerik:RadGrid>

0
Maria Ilieva
Telerik team
answered on 04 Feb 2013, 12:11 PM
Hello Shweta,

Could you please elaborate what the exact issue in handling the SelectedIndexChanged event on the server? Are you able to configure your requirements in case the RadGrid is not ajaxified? Some more information on the exact problem will help us further investigate the issue and advise you for a possible fix.

Greetings,
Maria Ilieva
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.
0
MTC
Top achievements
Rank 1
answered on 07 Feb 2013, 09:45 AM
Hello Maria,

That issue is solved now.
Now i have another one.and i want u to help me on this..
i am using RadAjaxManager in the rad grid. 
on button click i am updating a record in database and after successful update i want the grid also to be updated without postback.
i have tried with Rebind() and DataBind() but both are not working for me.
also i want to specify that i am using advance data binding (NeedDataSource).

  <telerik:RadAjaxManager ID="tlkRadAjaxMgr" runat="server" DefaultLoadingPanelID="tlkRadAjaxLoadingPanels">
                       <AjaxSettings>
                           <telerik:AjaxSetting AjaxControlID="rg_ViewTickets">
                                <UpdatedControls>
                                   <telerik:AjaxUpdatedControl ControlID="rg_ViewTickets" />
                                     <telerik:AjaxUpdatedControl ControlID="btnUpdate" />
                                </UpdatedControls>
                           </telerik:AjaxSetting>
                        </AjaxSettings>
                   </telerik:RadAjaxManager>

0
MTC
Top achievements
Rank 1
answered on 12 Feb 2013, 11:35 AM
Hi All..
I am using RadAjaxManager and RadAjaxLoadingPanel with RadGrid. On grid column i have asp linkbutton and on that link button click i am calling one javascript function..
everything is working fine but on that link button click i am not able to show loading panel and also post back occurs :(
below is my code :

 ajax setting is :
 <telerik:AjaxSetting AjaxControlID="lnkbtnDownload">
                                <UpdatedControls>
                                    <telerik:AjaxUpdatedControl ControlID="rg_Attachments" LoadingPanelID="tlkRadAjaxLoadingPnl" />
                                </UpdatedControls>
                            </telerik:AjaxSetting>
On Grid i have asp link button on  GridTemplateColumn like:

  <telerik:GridTemplateColumn HeaderText="Download">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClientClick="return downloadpdf(id);"
                                            ForeColor="Blue"></asp:LinkButton>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>

and this is my javascript function:
 <script language="javascript" type="text/javascript">
        function downloadpdf(id) {
            var annid = id.replace("lnkDownload", "annId");
            window.location = "DownloadAttachment.ashx?id=" + document.getElementById(annid).value;
            return false;
        }
    </script>


Please help........






0
Princy
Top achievements
Rank 2
answered on 12 Feb 2013, 12:09 PM
Hi,

I suppose you want to show loading panel on button click. Here is the sample code.
C#:
protected void LinkButton1_Click(object sender, EventArgs e)
{
       System.Threading.Thread.Sleep(2000);
}

Thanks,
Princy
0
Maria Ilieva
Telerik team
answered on 12 Feb 2013, 10:18 PM
Hello Shweta,

Please ensure that you have ScriptManager on the top of the page before the RadAjaxManager declaration and the RadAjaxLoadingPanel has Skin property set.


All the best,
Maria Ilieva
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.
Tags
Grid
Asked by
Nixon
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
MTC
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or