Jan 25, 2016, 4:34 PM
Cannot read property 'documentElement' of null
Hello,
I am having an issue exporting a filtered gridview to excel using 3.1, VB.net with asp.net MVC. I've done many other export to excel operations before in this exact framework, and have never run into this issue for them. Here is my setup:
aspx GridView and Store definition:
Export To excel button code:
Export to Excel Code in Controller:
The String that is passed back to the controller is a JSON string:
Thank you for any help you can give.
I am having an issue exporting a filtered gridview to excel using 3.1, VB.net with asp.net MVC. I've done many other export to excel operations before in this exact framework, and have never run into this issue for them. Here is my setup:
aspx GridView and Store definition:
<ext:GridPanel ID="gpMarginMatrix"
runat="server"
MaxHeight="500"
autoscroll="true"
Width ="974"
EnableViewState ="true">
<Store>
<ext:Store ID="dsMarginMatrix"
runat="server"
RemoteSort="true">
<Proxy>
<ext:AjaxProxy Url="/Data/MarginMatrixDataNew/" Timeout="1200000">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" IDProperty="mxmid" SuccessProperty="Success" MessageProperty="Message" />
</Reader>
<Writer>
<ext:JsonWriter Root="data" />
</Writer>
<Listeners>
<Exception Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
</Listeners>
</ext:AjaxProxy>
</Proxy>
Export To excel button code:
<ext:Button ID="btnExcel" runat="server" Text="To Excel" Icon="PageExcel">
<Listeners>
<Click Handler="
Ext.net.DirectMethod.request({
url : '/Data/ExportMginMtrxToExcel/',
params : {
data : Ext.encode(#{gpMarginMatrix}.getRowsValues({ visibleOnly:true }))
}
});
" />
</Listeners>
</ext:Button>
Export to Excel Code in Controller:
Public Function ExportMginMtrxToExcel(ByVal data As String) As ActionResult
Dim filename As String = "MatrixMargins" + DateTime.Now().ToString()
'Dim ds = Ext.Net.JSON.Serialize(data)
Dim submitData As New Ext.Net.SubmitHandler(data)
Dim xml As XmlNode = submitData.Xml
Dim sb As New StringBuilder
Dim writer As Global.System.Xml.XmlWriter = Global.System.Xml.XmlWriter.Create(sb)
Dim xt As New XslCompiledTransform
xt.Load(Server.MapPath("/Content/xsl/Excel.xsl"))
xt.Transform(xml, writer)
Dim result As FileContentResult = Nothing
result = New FileContentResult(Encoding.UTF8.GetBytes(sb.ToString()), "application/vnd.ms-excel")
result.FileDownloadName = filename + ".xls"
Return result
End Function
The String that is passed back to the controller is a JSON string:
"[{"MarGroupID":1,"Profile":"High","CZ":"HZ","Term":6,"FMonth":"1","Margin":"0","HC_Med_Mar":"0","HC_Small_Mar":"0","mxmid":481}]"
however i get this error as an EXT popup afterwards:Status Code: 200
Status Text: BADRESPONSE: Cannot read property 'documentElement' of null
There are no errors stepping through the code, and everything appears to be running without error. I read in another thread that you told someone to add in <AjaxEventConfig IsUpload="true" />
however i tried following this example but this tag no longer exists in 3.1? Thank you for any help you can give.
Last edited by geoffrey.mcgill; Apr 26, 2016 at 3:22 PM.