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

Download File in RadGrid button, use loadingpanel, can show, but can't hide.

2 Answers 382 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Me
Top achievements
Rank 1
Me asked on 21 Apr 2014, 04:00 AM
I do download function inside RadGrid, and want to show loadingpanel when press download button and hide loadingpanel when download finish.
Now, I can download file and show loadingpanel but can't hide loadingpanel.
Please Help me. Thanks.
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
  
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        var currentLoadingPanel = null;
        var currentUpdatedControl = null;
        function RequestStart(sender, args) {
            args.set_enableAjax(false);
            currentLoadingPanel = $find("<%= RadAjaxLoadingPanel1.ClientID%>");
            currentUpdatedControl = "<%= RadGrid1.ClientID%>";
            currentLoadingPanel.show(currentUpdatedControl);
        }
        function ResponseEnd(sender, args) {
            //hide the loading panel and clean up the global variables            
            if (currentLoadingPanel != null) {
                currentLoadingPanel.hide(currentUpdatedControl);
            }
            currentUpdatedControl = null;
            currentLoadingPanel = null;
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"/>
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
    <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd"></ClientEvents>
      
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Glow">
</telerik:RadAjaxLoadingPanel>
 
 
<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" Culture="zh-TW"
        DataSourceID="SqlDataSource1" GridLines="None" OnItemCommand="RadGrid1_ItemCommand">
        <MasterTableView AllowNaturalSort="False" AutoGenerateColumns="False"
            CommandItemDisplay="Top" DataKeyNames="applylist_no" AllowPaging ="true" PageSize ="15"
            DataSourceID="SqlDataSource1" NoMasterRecordsText="無資料" HierarchyLoadMode="Client"
            EnableHierarchyExpandAll="true">
            <DetailTables>
                <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2"
                    AutoGenerateColumns="False" HierarchyLoadMode ="Client"  >
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="applylist_no"
                            MasterKeyField="applylist_no" />
                    </ParentTableRelation>
                    <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False" />
 
                    <Columns>
                        <telerik:GridBoundColumn DataField="data_type" FilterControlAltText="Filter type column"
                            HeaderText="類別" SortExpression="data_type" UniqueName="data_type">
                        </telerik:GridBoundColumn>
                        <telerik:GridCalculatedColumn UniqueName="year" SortExpression="year_history" HeaderText="年份"
                            DataFields="year_history,year_ipccar4,year_wrf" Expression='{0} + "" + {1}+ "" + {2}'
                            FooterText="CalculatedColumn footer">
                        </telerik:GridCalculatedColumn>
                        <telerik:GridCalculatedColumn DataFields="parameter_history,parameter_ipccar4,parameter_tri"
                            Expression='{0} + "" + {1}+ "" + {2}' FilterControlAltText="Filter parameter column"
                            HeaderText="參數" UniqueName="parameter">
                        </telerik:GridCalculatedColumn>
                        <telerik:GridBoundColumn DataField="theme" FilterControlAltText="Filter theme column"
                            HeaderText="情境" SortExpression="theme" UniqueName="theme">
                        </telerik:GridBoundColumn>
                        <telerik:GridCalculatedColumn DataFields="area_history,area_ipccar4,area_wrf" Expression='{0} + "" + {1}+ "" + {2}'
                            FilterControlAltText="Filter area column" HeaderText="地區" UniqueName="area">
                        </telerik:GridCalculatedColumn>
                        <telerik:GridTemplateColumn  HeaderText="審核是否通過" SortExpression="reject" UniqueName="reject">
                            <ItemTemplate >
                                <asp:Label ID="Label2" runat="server" Text='<%# WrapText(Eval("reject"))%>'></asp:Label>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
 
                    <ItemStyle HorizontalAlign="Center" />
                    <AlternatingItemStyle HorizontalAlign="Center" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <CommandItemStyle HorizontalAlign="Center" />
                </telerik:GridTableView>
            </DetailTables>
 
 
            <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton ="false" />
            <Columns>
                <telerik:GridBoundColumn DataField="applylist_no"
                    FilterControlAltText="Filter applylist_no column" HeaderText="申請單號"
                    ReadOnly="True" SortExpression="applylist_no" UniqueName="applylist_no">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="date_apply" DataType="System.DateTime"
                    FilterControlAltText="Filter date_apply column" HeaderText="送審日期"
                    SortExpression="date_apply" UniqueName="date_apply">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="deadline_download"
                    DataType="System.DateTime"
                    FilterControlAltText="Filter deadline_download column"
                    HeaderText="下載有效期限" SortExpression="deadline_download"
                    UniqueName="deadline_download" DataFormatString="{0:yyyy/MM/dd}">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Download"
                    FilterControlAltText="Filter download column" HeaderText="下載" Text="下載檔案"
                    UniqueName="download">
                </telerik:GridButtonColumn>
            </Columns>
            <ItemStyle HorizontalAlign="Center" />
            <AlternatingItemStyle HorizontalAlign="Center" />
            <HeaderStyle HorizontalAlign="Center" />
            <CommandItemStyle HorizontalAlign="Center" />
        </MasterTableView>
    </telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 23 Apr 2014, 12:00 PM
Hi,

Note that the MS Ajax framework does not supports downloading files using Response.Write method. Please review the following help articles which describe how to download files and make sure you are using the provided approach

Download files

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
期涛
Top achievements
Rank 1
answered on 29 May 2018, 10:06 AM
谢谢
Tags
Ajax
Asked by
Me
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
期涛
Top achievements
Rank 1
Share this question
or