This is a migrated thread and some comments may be shown as answers.
Display message during/after export
3 Answers 60 Views
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 01 Apr 2010, 01:37 PM

My application produces a very large report that has the requirement of being exported (Excel, PDF, CSV).  From reading several threads here about problems with exporting large files and running into the issue myself, I took the approach to limit what is being exported by changing the page size and setting Ignorepaging to false.  What I'd like to do is post back an message/alert something to the user to let them know that what they tried to export was too large and the records were limited to x number.  My problem is that no matter what I've tried a message doesn't get displayed.  My app has  user control on the page that is meant to display messages that isn't working (pgMessage in code). I've tried adding a literal control to the bottom of the Grid as suggested in a form thread.  That didn't work,  I've tried using RegisterStartupscript with an alert.  That hasn't worked.   I've moved all of the above to different events like ItemCommand, Exporting, Pre_Render but I haven't found any that works.  My grid is ajaxified and I've followed the manuals approach on exporting an ajaxified grid.

Any one have any suggestions?

ASPX:

    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">    
        <AjaxSettings> 
           <telerik:AjaxSetting AjaxControlID="lnkbtnSave">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rcbRptSettings"   
                        LoadingPanelID="" /> 
                </UpdatedControls>                  
            </telerik:AjaxSetting>   
            <telerik:AjaxSetting AjaxControlID="lnkbtnSaveAs">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rcbRptSettings"   
                        LoadingPanelID="" /> 
                </UpdatedControls>                  
            </telerik:AjaxSetting>                     
            <telerik:AjaxSetting AjaxControlID="rcbRptSettings">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rcbRptSettings" /> 
                    <telerik:AjaxUpdatedControl ControlID="rdpbegin" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="rdpend" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbCodeList" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbListType" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnAddCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="rlbCodes" /> 
                    <telerik:AjaxUpdatedControl ControlID="rlbFields" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbGroupSort" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting>         
            <telerik:AjaxSetting AjaxControlID="rcbCodeList">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rcbListType"   
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnAddCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="rlbCodes"   
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="rcbListType">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rtbCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnAddCode" />                              
                    <telerik:AjaxUpdatedControl ControlID="rlbCodes"   
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnAddCode">  
                <UpdatedControls>                              
                    <telerik:AjaxUpdatedControl ControlID="rtbCode"   
                        LoadingPanelID="RadAjaxLoadingPanel1" />   
                    <telerik:AjaxUpdatedControl ControlID="rlbCodes"   
                        LoadingPanelID="RadAjaxLoadingPanel1" />    
                </UpdatedControls>                  
            </telerik:AjaxSetting>              
            <telerik:AjaxSetting AjaxControlID="btnSearch">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lnkbtnSave" /> 
                    <telerik:AjaxUpdatedControl ControlID="lnkbtnSaveAs" /> 
                    <telerik:AjaxUpdatedControl ControlID="ARGrid1" /> 
                </UpdatedControls>                  
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnReset">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="rdpbegin" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="rdpend" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbCodeList" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbListType" /> 
                    <telerik:AjaxUpdatedControl ControlID="rtbCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnAddCode" /> 
                    <telerik:AjaxUpdatedControl ControlID="rlbCodes" /> 
                    <telerik:AjaxUpdatedControl ControlID="rlbFields" /> 
                    <telerik:AjaxUpdatedControl ControlID="rcbGroupSort" /> 
                    <telerik:AjaxUpdatedControl ControlID="ARGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="ARGrid1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="ARGrid1"   
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManagerProxy> 
 
......  
 
<pm:PgMsg ID="PgMessage" runat="server" /> 
 
......  
                    <telerik:RadGrid ID="ARGrid1" runat="server" Width="97%" Height="95%" GridLines="None" PageSize="40" EnableAjaxSkinRendering="true" 
                         AllowSorting="true" AllowPaging="true" Visible="false" OnNeedDataSource="ARGrid1_NeedDataSource" OnItemCreated="ARGrid1_ItemCreated" 
                         OnItemCommand="ARGrid1_ItemCommand" OnGridExporting="ARGrid1_Exporting" ShowStatusBar="true" ShowGroupPanel="true" Skin="Outlook">  
                         <MasterTableView AllowFilteringByColumn="true" AllowMultiColumnSorting="true" Width="100%" CommandItemDisplay="Top" ShowGroupFooter="false" AutoGenerateColumns="true">  
                            <HeaderStyle Width="200px" /> 
                            <Columns></Columns>  
                            <CommandItemSettings AddNewRecordText="" ShowExportToPdfButton="true" ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" /> 
                         </MasterTableView> 
                         <ClientSettings AllowColumnsReorder="true" AllowDragToGroup="true" ColumnsReorderMethod="Reorder" EnableRowHoverStyle="true">  
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="false" FrozenColumnsCount="0" ScrollHeight="100%" /> 
                            <Resizing ClipCellContentOnResize="false" AllowColumnResize="true" /> 
                         </ClientSettings> 
                         <GroupingSettings ShowUnGroupButton="true" RetainGroupFootersVisibility="false" /> 
                         <ExportSettings IgnorePaging="true" OpenInNewWindow="true">  
                            <Pdf AllowPrinting="true" /> 
                         </ExportSettings> 
                    </telerik:RadGrid> 
 
 
 

 

function onRequestStart(ajaxManager, eventArgs) {

 

 

if ((eventArgs.EventTarget == "ARGrid1") && (cancelAjax)) {

 

eventArgs.EnableAjax =

false;

 

}

 

//Uncomment the line below in case of a file download.

 

 

//cancelAjax = false;

 

 

if (eventArgs.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||

 

eventArgs.get_eventTarget().indexOf(

"ExportToWordButton") >= 0 ||

 

eventArgs.get_eventTarget().indexOf(

"ExportToPdfButton") >= 0 ||

 

eventArgs.get_eventTarget().indexOf(

"ExportToCsvButton") >= 0) {

 

eventArgs.set_enableAjax(

false);

 

}

 

 

//Used to display ajax graphic(twirly) over gridPane

 

currentLoadingPanel = $find(

"<%= RadAjaxLoadingPanel1.ClientID %>");

 

 

if (eventArgs.get_eventTarget() == "<%= btnSearch.UniqueID %>") {

 

currentUpdatedControl =

"<%= gridPane.ClientID %>";

 

}

 

//show the loading panel over the updated control

 

currentLoadingPanel.show(currentUpdatedControl);

 

 

}

 

CodeBehind:  I've commented out most to the code I've tried. The last attempt was with RegisterStartupScript.
      protected void Page_PreRender(object sender, EventArgs e)  
        {  
            //if (exportMsg != string.Empty)  
            //{  
            //    PgMessage.DisplayMessage(PageMessage.MessageType.Information, exportMsg);  
            //    exportMsg = string.Empty;  
            //}  
           ARGrid1.EnableAjaxSkinRendering = true;        
        }  
          
        protected void Page_Load(object sender, EventArgs e)  
        {  
            //Set up client side calls for AjaxProxyManager  
            RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);  
            manager.ClientEvents.OnRequestStart = "onRequestStart";  
            manager.ClientEvents.OnResponseEnd = "onResponseEnd";  
            manager.AjaxSettingCreated += new RadAjaxControl.AjaxSettingCreatedDelegate(manager_AjaxSettingCreated);  
            manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);  
 
 
            //Ajaxify user control for controls            
            Control mainPlaceHolder = Master.FindControl("MainPH");  
            Control pgMsg = mainPlaceHolder.FindControl("pgMessage");  
 
            RadAjaxLoadingPanel ajaxLoadingPanel = Master.FindControl("RadAjaxLoadingPanel1") as RadAjaxLoadingPanel;  
            manager.AjaxSettings.AddAjaxSetting(btnSearch, pgMsg, ajaxLoadingPanel);  
            manager.AjaxSettings.AddAjaxSetting(btnAddCode, pgMsg, ajaxLoadingPanel);  
            manager.AjaxSettings.AddAjaxSetting(lnkbtnSave, pgMsg, ajaxLoadingPanel);  
            manager.AjaxSettings.AddAjaxSetting(lnkbtnSaveAs, pgMsg, ajaxLoadingPanel);  
            manager.AjaxSettings.AddAjaxSetting(btnReset, pgMsg, ajaxLoadingPanel);  
            manager.AjaxSettings.AddAjaxSetting(ARGrid1, pgMsg, ajaxLoadingPanel);  
 
 
            PgMessage.ClearMessages();  
 
            //Render user control    
 
            if (!Page.IsPostBack)  
            {  
                BindSavedSettings(Master.loggedUser.UserReports);  
                BindCodeList();  
                BindListType();  
                BuildFieldList();  
            }  
 
            //RadComboBox1.Items.Add(new RadComboBoxItem("Add Item","Add Item"));                         
        }       
 
 
 
 
 
 
 
   protected void ARGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)  
        {  
            if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName ||  
                e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName ||  
                e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName ||  
                e.CommandName == Telerik.Web.UI.RadGrid.ExportToPdfCommandName)  
            {  
                ConfigureExport();  
            }  
        }  
 
        private void DisplayMessageInRadGrid(string text)  
        {  
            // This places a nicely formatted message in the bottom row of the grid  
            ARGrid1.Controls.Add(new LiteralControl(text));  
        }  
 
        public void ConfigureExport()  
        {  
            //int gridCount = 0;  
            ////Get the total number of rows in the grid.  (Should take into account filters)  Done this way per Telerik.  Otherwise only get current pagesize  
            //ARGrid1.AllowPaging = false;  
            //ARGrid1.Rebind();  
            //gridCount = ARGrid1.MasterTableView.Items.Count;  
            //ARGrid1.AllowPaging = true;  
            //ARGrid1.Rebind();  
 
 
            ARGrid1.ExportSettings.ExportOnlyData =  true; //CheckBox1.Checked;  
            ARGrid1.ExportSettings.OpenInNewWindow = true; //CheckBox3.Checked;  
 
            if ((int)Session["itemsCount"] > 2000)  
            {  
                exportMsg = "Export exceeds record limit. Export was cut to 2000 records";  
                //DisplayMessageInRadGrid(exportMsg);  
                //PgMessage.DisplayMessage(PageMessage.MessageType.Information, "Export exceeds record limit. Export was cut to 2000 records");  
                  
                //*****  
            //***********************************************************  
            //Build cooresponding java script functions  
            //***********************************************************  
            // Get a ClientScriptManager reference from the Page class.  
            Type cstype = this.GetType();  
            ClientScriptManager cs = Page.ClientScript;  
            // Check to see if the startup script is already registered.  
            if (!cs.IsStartupScriptRegistered(cstype, "returnScript"))  
            {  
                //Build code to post back save/cancel button clicks  
                System.Text.StringBuilder cstext = new System.Text.StringBuilder();  
                cstext.AppendLine("<script type=\"text/javascript\">");  
                cstext.AppendLine("alert('" + exportMsg + "');");  
                cstext.AppendLine("</script>");  
                cs.RegisterStartupScript(cstype, "returnScript", cstext.ToString(), false);  
 
            }  
                //*******  
                DisplayMessageInRadGrid(exportMsg);  
                ARGrid1.ExportSettings.IgnorePaging = false; //CheckBox2.Checked;  
                ARGrid1.PageSize = 2000;  
                ARGrid1.Rebind();                  
            }  
            else  
            {  
                ARGrid1.ExportSettings.IgnorePaging = true; //CheckBox2.Checked;  
            }  
        }  
 
         protected void ARGrid1_Exporting(object source, Telerik.Web.UI.GridExportingArgs e)  
        {  
            isExport = true;  //sets exporting to true  
            //if (isExport && exportMsg != string.Empty)  
            //{  
            //    PgMessage.DisplayMessage(PageMessage.MessageType.Information, exportMsg);  
            //    exportMsg = string.Empty;  
            //}  
                
        } 

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 01 Apr 2010, 11:17 PM
Hello Michael,

Please examine the following forum thread and let me know whether the suggested workaround is feasible for your scenario.
Display Loading Panel during Export

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael
Top achievements
Rank 1
answered on 02 Apr 2010, 06:30 PM
Thanks Daniel. I've been working with this a little today.  I'm not sure it will work for my application but it is pretty slick.  One thing I haven't been able to figure out is out to close the progressarea when the export is finished..  It seems to hang up and stay visible.  Is there a way to auto close it like in the upload file examples?

Also is there another option I'd have to display a message that the export has been trimmed to X number due to possible insufficient memory?

Thanks
0
Daniel
Telerik team
answered on 08 Apr 2010, 04:32 PM
Hello Michael,

There is no easy way to hide the progress area automatically. I attached a simple demo to this post - please note that you may need to fine tune the timeout.

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Michael
Top achievements
Rank 1
Share this question
or