RADGRID in asp panel Ajaxified

3 posts, 0 answers
  1. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 06 Jan 2014 Link to this post

    After looking through MANY forum thread regarding export to CSVwith an ajaxified regular asp panel, including downloading all of the example projects, I have not been able to resolve the issue.

    The goal is to have a loading panel display until the grid is completely data bound and then have the loading panel hide and display the panel containing the radgrid.

    Everything works great EXCEPT exporting the data to CSV. Any help much appreciated:

    CODE:

    <%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/default.master"
        CodeFile="addresses_non_mic_users.aspx.vb" Inherits="_Default" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="cph_Head" runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="cph_Body" runat="Server">
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function pageLoad(sender, eventArgs) {
                    if (!eventArgs.get_isPartialLoad()) {
                        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad");
                    }
                }     
            </script>
            <script type="text/javascript">
                function onRequestStart(sender, args) {
                    if (args.get_eventTarget().indexOf("ExportToCsvButton") >= 0)
                        args.set_enableAjax(false);
                }
         
            </script>
        </telerik:RadCodeBlock>
        <h1>
            Members not Registered in MIC</h1>
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                <td style="padding: 3px; width: 135px; font-weight: bold; font-size: medium; text-align: right;
                    color: #008000;">
                    Total Addresses:
                </td>
                <td>
                    <asp:Label ID="lbl_Count" runat="server" Font-Size="Medium"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 135px">
                      
                </td>
                <td>
                      
                </td>
            </tr>
        </table>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page,
         "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' />
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:Panel ID="Panel1" runat="server">
            <asp:Panel ID="Panel2" Visible="false" runat="server">
                <telerik:RadGrid ID="rgd_User_List" runat="server" AllowPaging="True" AllowSorting="True"
                    CssClass="radgrid" DataSourceID="sds_Address_Lookup" GridLines="None" PageSize="2000">
                    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                    </ClientSettings>
                    <PagerStyle AlwaysVisible="true" HorizontalAlign="Center" Mode="NextPrevAndNumeric"
                        Position="TopAndBottom" PagerTextFormat=" {4} {5} Addresses in {1} pages " />
                    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataSourceID="sds_Address_Lookup"
                        HeaderStyle-HorizontalAlign="Center">
                        <CommandItemSettings ShowAddNewRecordButton="False" ShowExportToCsvButton="True"
                            ShowRefreshButton="False" />
                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn>
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridBoundColumn DataField="Full_Name" FilterControlAltText="Filter Full_Name column"
                                HeaderText="Name" SortExpression="Full_Name" UniqueName="Full_Name">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="PIN" FilterControlAltText="Filter PIN column"
                                HeaderText="PIN" SortExpression="PIN" UniqueName="PIN">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ADDRESS1" FilterControlAltText="Filter ADDRESS1 column"
                                HeaderText="Address 1" SortExpression="ADDRESS1" UniqueName="ADDRESS1">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ADDRESS2" FilterControlAltText="Filter ADDRESS2 column"
                                HeaderText="Address 2" SortExpression="ADDRESS2" UniqueName="ADDRESS2">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="CITY" FilterControlAltText="Filter CITY column"
                                HeaderText="City" SortExpression="CITY" UniqueName="CITY">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="State" FilterControlAltText="Filter State column"
                                HeaderText="State" ReadOnly="True" SortExpression="State" UniqueName="State">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="ZIP" FilterControlAltText="Filter ZIP column"
                                HeaderText="Zip" SortExpression="ZIP" UniqueName="ZIP">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="COUNTRY" FilterControlAltText="Filter COUNTRY column"
                                HeaderText="Country" SortExpression="COUNTRY" UniqueName="COUNTRY">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>
            </asp:Panel>
        </asp:Panel>
        <asp:SqlDataSource ID="sds_Address_Lookup" runat="server" ConnectionString="<%$ ConnectionStrings:DAC_PGOLD_ConnectionString %>"
            SelectCommand="SELECT * FROM [vw_Addresses_Non_MIC_Users] ORDER BY Full_Name">
        </asp:SqlDataSource>
    </asp:Content>


    Imports System.Data
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI
    Imports System.CodeDom
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.Security.Roles
    Imports System.Web.Security.Membership
    Imports System.Security
    Imports System.Security.Principal.WindowsIdentity
    Imports System.DirectoryServices
    Imports System.DirectoryServices.AccountManagement
     
    Partial Class _Default
        Inherits System.Web.UI.Page
     
     
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
     
            Dim cn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("DAC_PGOLD_ConnectionString").ToString)
            cn.Open()
            Dim SqlCmd As SqlCommand
     
            SqlCmd = New SqlCommand("SELECT COUNT(ENTITY_ID) FROM [vw_Addresses_Non_MIC_Users]", cn)
     
            Dim Count = CType(SqlCmd.ExecuteScalar, Integer)
     
            lbl_Count.Text = String.Format("{0:N0}", Count)
     
            cn.Close()
     
        End Sub
     
     
        Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
            If e.Argument = "InitialPageLoad" Then
                Panel2.Visible = True
            End If
     
        End Sub
     
     
        Protected Sub rgd_User_List_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgd_User_List.ItemCommand
            If e.CommandName = Telerik.Web.UI.RadGrid.ExportToCsvCommandName Then
                rgd_User_List.ExportSettings.IgnorePaging = True
            End If
        End Sub
     
    End Class

    Thank you in advance.




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

    Posted 06 Jan 2014 Link to this post

    Hi Allen,

    Please set AjaxControlID="Panel1" in your AjaxManager code as below:

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 07 Jan 2014 Link to this post

    Thank you as always Princy.

    You answer lead me to a solution that works. Here is how I have set the RadAjaxManager and everything seems to work correctly now:


    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>



Back to Top