Sep 04, 2013, 7:29 AM
[CLOSED] close Ext.Net Window after export to excel
Hi ,
I am exporting set of data to excel using some 3rd party control. The feature is working fine and i get the exported contents in excel.
I have used a ext.net window that has "FileName" textfield and "Export" button as below:
How can i achieve that? What is missing.
Please let me know
I am exporting set of data to excel using some 3rd party control. The feature is working fine and i get the exported contents in excel.
I have used a ext.net window that has "FileName" textfield and "Export" button as below:
@(Html.X().Window()
.Title("Export")
.Hidden(true)
.Width(750)
.ID("ViewPopUp")
.Height(400)
.Layout(LayoutType.Fit)
.Icon(Icon.Application)
.Items
(
X.Container().ID("cntExport")
.Items(
X.TextField().ID("txtExpFName"),
X.Button().ID("btnExp").Text("Export").Listeners(l => l.Click.Fn ="ExportClick1")
)
))
On the Click i have below code: Ext.net.DirectMethod.request({
url: '@Url.Action("Export", "Results")',
cleanRequest: true,
isUpload: true,
params: {
id: someid
},
success: function (data)
{
if (data.data == 'No data Found')
{
Ext.Msg.alert('Error', 'Cannot Export with no data.');
}
App.ViewPopUp.close();
},
failure: function (result)
{
}
});
and my MVC action is as below:public ActionResult Export(int id)
{
var result = _svc.getData(id)
if (result.Count == 0)
{
return new DirectResult(new { data = "No data Found" }) { IsUpload = true };
}
else
{
HttpContext.Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment;filename={0}{1}", fileName, ".xlsx"));
Response.Charset = "";
Response.ContentType = "application/vnd.xlsx";
Response.OutputStream.Write(result, 0, result.Length);
Response.Flush();
Response.End();
return this.Direct();
}
}
So when there is no result it comes in the success function . But if there is some result it writes to response and show it in the browser as dialog but it doesnt not close the ext.net window.How can i achieve that? What is missing.
Please let me know
Last edited by Daniil; Sep 10, 2013 at 5:30 AM.
Reason: [CLOSED]