RadAjaxManager is breaking paging for RadGrid

4 posts, 1 answers
  1. Mike
    Mike avatar
    3 posts
    Member since:
    May 2012

    Posted 09 May 2012 Link to this post

    I've been tasked with applying a loading panel over a RadGrid that is nested in an UpdatePanel. I placed a RadAjaxManager and a RadAjaxLoadingPanel inside the update definition. The loading panel works, but for some reason, the paging on the RadGrid breaks, and it alternates between doing a full page refresh and a proper AJAX request. I've tried to replace the UpdatePanel with a RadAjaxPanel, but that didn't fix the problem, and in fact started mangling the RadGrid display.
    Here's the code that's causing the problem. Any info would be appreciated. Thanks!

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
           <ContentTemplate>
                <radG:RadAjaxManager ID="RadAjaxManager1" runat="server">
                   <AjaxSettings>
                       <radG:AjaxSetting AjaxControlID="btnSearch">
                           <UpdatedControls>
                               <radG:AjaxUpdatedControl ControlID="UpdatePanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                           </UpdatedControls>
                       </radG:AjaxSetting>
                   </AjaxSettings>
              </radG:RadAjaxManager>
              <radG:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2007" >
              </radG:RadAjaxLoadingPanel>
               
                 <radG:RadGrid ID="grdCampaignStatus" runat="server" PageSize="50" Width="100%" Height="565px" Skin="Office2007"
                   EnableEmbeddedSkins="true" GridLines="None" AllowPaging="true" AutoGenerateColumns="False"
                   AllowSorting="true" ShowGroupPanel="False" StatusBarSettings-ReadyText="Ready"
                   StatusBarSettings-LoadingText="Please Wait..." ShowStatusBar="True">
                   <ClientSettings AllowDragToGroup="True">
                       <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True">
                       </Resizing>
                       <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
                   </ClientSettings>
                   <MasterTableView AllowNaturalSort="false" TableLayout="Fixed">
                       <Columns>
                           <radG:GridBoundColumn SortExpression="Campaign Id" AllowSorting="True" HeaderText="Campaign Id"
                               DataField="[Campaign Id]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Campaign Name" AllowSorting="true" SortExpression="Campaign Name" DataField="[Campaign Name]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Status" AllowSorting="true" SortExpression="Status" DataField="[Status]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Placed Date" AllowSorting="true" SortExpression="Placed Date" DataField="[Placed Date]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Requested launch Date/Time" AllowSorting="true" SortExpression="Requested Launch" DataField="[Requested Launch]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Date/Time sent" AllowSorting="true" SortExpression="Time Sent" DataField="[Time Sent]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="First Name" AllowSorting="true" SortExpression="First Name" DataField="[First Name]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Last Name" AllowSorting="true" SortExpression="Last Name" DataField="[Last Name]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Reply To" AllowSorting="true" SortExpression="Reply To" DataField="[Reply To]">
                           </radG:GridBoundColumn>
                           <radG:GridBoundColumn HeaderText="Recipient Count" AllowSorting="true" HeaderStyle-Width="50" SortExpression="Recipient Count" DataField="[Recipient Count]">
                           </radG:GridBoundColumn>
                           
                           <radG:GridTemplateColumn HeaderText="Run" UniqueName="TemplateColumn" HeaderStyle-Width="30">
                               <ItemTemplate>
                                   <asp:Button ID="LinkButtonRedistribute"    CommandName="ExecuteService" OnClientClick = "return confirm('Do you want to run the campaign service?');"  
                                       CommandArgument='<%# DataBinder.Eval(Container.DataItem,"[Campaign Id]") %>' runat="server"
                                       Text="Run"></asp:Button>
                               </ItemTemplate>
                           </radG:GridTemplateColumn>
                            
                           <radG:GridTemplateColumn HeaderText="Complete" UniqueName="CompleteColumn" >
                               <ItemTemplate>
                                   <asp:Button ID="LinkButtonCompleteCampaign" Width="60"   CommandName="CompleteCampaign" OnClientClick = "return confirm('This will only update the status of the campaign to Completed. This will not send any notification or send any emails. Do you want to complete the campaign? ');"  
                                       CommandArgument='<%# DataBinder.Eval(Container.DataItem,"[Campaign Id]") %>' runat="server"
                                       Text="Complete"></asp:Button>
                               </ItemTemplate>
                           </radG:GridTemplateColumn>
                            
                            
                       </Columns>
                   </MasterTableView>
                   <PagerStyle Mode="NumericPages" />
               </radG:RadGrid>
           </ContentTemplate>
           <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
               <asp:AsyncPostBackTrigger ControlID="uxCampaignStatus" EventName="SelectedIndexChanged" />           
           </Triggers>
       </asp:UpdatePanel>

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 May 2012 Link to this post

    Hello Mike,

    I also tried the same scenario and was able to replicate the issue when the grid is binded using simple data binding. Can you please make sure that you are using Advanced data binding using its NeedDataSource event?

    Thanks,
    Princy.
  3. Mike
    Mike avatar
    3 posts
    Member since:
    May 2012

    Posted 10 May 2012 Link to this post

    Thanks for the advice. I'll give it a try when I have time and I'll report back with my results.
    Mike
  4. Mike
    Mike avatar
    3 posts
    Member since:
    May 2012

    Posted 10 May 2012 Link to this post

    Well, it looks like the NeedDataSource event is implemented, but it wasn't doing what I needed it to and would take too much work to get it right. I ended up ditching the RadAjaxLoadingPanel in favor of just showing a client-side image through an onClientClick event when the search button is clicked. To hide the image after the UpdatePanel refreshes I used RegisterStartupScript to inject some Javascript to turn it off. My solution isn't the most elegant, but it works for my purposes. Thanks for pointing out what the problem was though. I think this app is going to be rewritten soon as it is almost 10 years old. Maybe we can get it right the second time around!

    Here's the code I used to hide the image after the UpdatePanel completes:

    ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "hide", "<script type='text/javascript'>document.getElementById('spinnerImage').style.display='none';</script>", False)

Back to Top