AnsweredAssumed Answered

Trouble with Datagrid export CSV

Question asked by chyang0107 on Feb 6, 2014
Latest reply on Mar 4, 2015 by MayMay
Hi Everyone,

I found the post related to Datagrid to .csv file useful. I followed the instructions to have these codes in my web application and .ashx file. I could draw a box to select the features. However, it failed to export the file and a error message was shown in Chrome Web Console after clicking the button (Save to CSV),          Uncaught TypeError: Cannot read property 'structure' of undefined.

The web application is in jsbin

In addition, I have my web application file and MyWebHandler.ashx at the same folder

Please let me know how I fix this problem.

Many thanks,
Hank

The below code is the MyWebHandler.ashx file
public void ProcessRequest(HttpContext context)     {         context.Response.ContentType = "text/plain";         System.Collections.Specialized.NameValueCollection parameters = context.Request.Form;         string moduleName = parameters["module"];         string requestFeedback = "";         switch (moduleName)         {              case "ExportToExcel":                 EgisWeb.ExportHelper objExportCSVHelper = new EgisWeb.ExportHelper();                 objExportCSVHelper.CSV2Excel(parameters["csvdata"].ToString(), HttpContext.Current, parameters["title"].ToString());                 break;                      }         if (moduleName != "ExportToExcel")              context.Response.Write(requestFeedback);       }    public void CSV2Excel(string strCSV, HttpContext current, string strTitle)         {             current.Response.Clear();             strCSV = removeUniCodeSequenceCharacters(strCSV);             strCSV = System.Text.RegularExpressions.Regex.Unescape(strCSV);             current.Response.AddHeader("content-disposition", "attachment;filename=" + strTitle +"_"+DateTime.Now.ToString("ddmmyyyyHHMMSS") + ".csv");             current.Response.Charset = "";             current.Response.ContentType = "application/octet-stream";             current.Response.Write(strCSV);             current.Response.End();          }   private string removeUniCodeSequenceCharacters(string strWithEscapeSequence)         {             string strUse = "";             strUse = strWithEscapeSequence.Replace("%20", " ");             strUse = strUse.Replace("%2C", ",");             strUse = strUse.Replace("%27", "'");             strUse = strUse.Replace("%22", "\"");             strUse = strUse.Replace("%3F", "?");             strUse = strUse.Replace("%0A", "\n");             strUse = strUse.Replace("%28", "(");             strUse = strUse.Replace("%29", ")");             strUse = strUse.Replace("%26", "&");             strUse = strUse.Replace("%23", "#");             strUse = strUse.Replace("%3A", ":");             strUse = strUse.Replace("%21", "!");             strUse = strUse.Replace("%2D", "-");             strUse = strUse.Replace("%3B", ";");             strUse = strUse.Replace("%2A", "*");             strUse = strUse.Replace("%2B", "+");             strUse = strUse.Replace("%2E", ".");             strUse = strUse.Replace("%3C", "<");             strUse = strUse.Replace("%3D", "=");             strUse = strUse.Replace("%3E", ">");             strUse = strUse.Replace("%40", "@");             return strUse;         }

Outcomes