I have a radgrid with an export button which I was able to exclude from using ajax via ajaxmanager.
However I now require a prompt to the user to choose an option which affects the data that will be exported.
I use a custom rad prompt template to get a dropdownlist option and use a callback function in javascript which makes
an ajax request passing the parameter containing the dropdownlist option selected and then call my export function which no longer
works. Is there a good workaround so my export will still work after a prompt to the user?
Thanks for the help.
protected void rg_ClientCalculators_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "ExportCalculator") { ViewState["CalculatorID"] = int.Parse(e.CommandArgument.ToString()); RadWindowManager1.RadPrompt("Show all line items?", "callbackFn", 300, 300, null, "Calculator Export", " "); } }protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument == "Yes") ExportCalculator(true); else if (e.Argument == "No") ExportCalculator(false); } private void ExportCalculator(bool showAllLineItems) { Company UsersCompany = DAL.GetCompanyInfo(CurrentUser.UserID); var calculatorID = (int)ViewState["CalculatorID"]; DataTable CalculatorClientInfo = DAL.ExportCalculatorClientInfo(calculatorID); ReportProcessor Processor = new ReportProcessor(); InstanceReportSource ReportSource = new InstanceReportSource(); ClientTrackerReports.CalculatorExport Report = new CalculatorExport(); Report.ReportParameters["CalculatorID"].Value = calculatorID; Report.ReportParameters["CompanyName"].Value = UsersCompany.CompanyName; Report.ReportParameters["ClientName"].Value = CalculatorClientInfo.Rows[0]["ClientName"]; Report.ReportParameters["AnotherVendor"].Value = CalculatorClientInfo.Rows[0]["AnotherVendor"]; Report.ReportParameters["DateOfStatementProvided"].Value = CalculatorClientInfo.Rows[0]["DateOfStatementProvided"]; Report.ReportParameters["ShowAllLineItems"].Value = showAllLineItems; ReportSource.ReportDocument = Report; ViewState.Remove("CalculatorID"); Hashtable DeviceInfo = new Hashtable(); RenderingResult Result = Processor.RenderReport("PDF", ReportSource, DeviceInfo); string FileName = CalculatorClientInfo.Rows[0]["ClientName"].ToString() + "-Pricing." + Result.Extension; Response.Clear(); Response.ContentType = Result.MimeType; Response.Cache.SetCacheability(HttpCacheability.Private); Response.Expires = -1; Response.Buffer = true; Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", FileName)); Response.BinaryWrite(Result.DocumentBytes); Response.End(); }
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function callbackFn(arg) { if (arg) { $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(arg); } } </script> </telerik:RadCodeBlock> <telerik:RadWindowManager ID="RadWindowManager1" runat="server"> <PromptTemplate> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> function closePrompt(winid) { var select = document.getElementById('select' + winid); var selectedValue = select.options[select.selectedIndex].value; var confirmWnd = $find(winid); confirmWnd.close(selectedValue); } </script> </telerik:RadCodeBlock> <div class="windowpopup radprompt"> <div class="dialogtext"> {1} </div> <div> <select id="select{0}"> <option value="Yes">Yes</option> <option value="No">No</option> </select> </div> <div> <input type="button" onclick="closePrompt('{0}');" value="OK" /> <input type="button" onclick="$find('{0}').close();" value="Cancel" /> </div> </div> </div> </PromptTemplate> </telerik:RadWindowManager>