Tôi vẫn hy vọng có câu trả lời tốt hơn nhưng trong thời gian chờ đợi, giải pháp của tôi dường như đáp ứng các tiêu chí. Nó sử dụng Cửa sổ Web Kendo (vì vậy tôi cho rằng bạn có thể viết lý thuyết của riêng bạn bằng cách sử dụng jQuery). Tôi chưa sửa đổi nó để vượt qua các tham số, nhưng đó là một sự khởi đầu. Tôi cũng không bảo đảm hành động chuyển hướng, vì vậy hiện tại người dùng có thể xem nguồn, lấy URL từ tải jQuery, chuyển đến địa chỉ đó và nhận URL báo cáo cơ bản từ đó. Tôi sẽ xem xét đánh dấu nó như một ChildActionOnly hoặc một số phương tiện khác để bảo đảm rằng hành động chỉ có sẵn cho cửa sổ của tôi. Tôi cũng thấy rằng tôi có thể kết xuất báo cáo thành HTML4.0, nội dung trong FileResult và tải nội dung theo cách đó - nhưng sau đó báo cáo là HTML tĩnh.
Xem:
@(Html.Kendo().Grid(Model)
.Name("IndexGrid")
.Columns(col =>
{
col.Bound(c => c.SchoolYear);
col.Bound(c => c.SubmissionTypeDesc);
col.Bound(c => c.EntityDesc);
col.Bound(c => c.SubmissionDate);
col.Bound(c => c.UserName);
col.Bound(c => c.Certified);
col.Command(c =>
{
c.Custom("Edit")
.Text("View")
.Action("Edit", "Draft");
c.Custom("Preview")
.Click("windowOpen");
c.Custom("Certify")
.Action("Certify", "Draft");
c.Custom("Download")
.Action("DumpExcel", "Draft");
}
).Title("<b>Actions</b>")
.HtmlAttributes(new { style = "width:200px;" });
})
.DataSource(ds => ds.Server()
.Model(model => model.Id(pk => pk.snapshot_id))
)
.Sortable(sort => sort.Enabled(true).SortMode(GridSortMode.MultipleColumn).AllowUnsort(true))
.Reorderable(reorder => reorder.Columns(true))
.Groupable(group => group.Enabled(true))
)
</article>
@(Html.Kendo().Window()
.Name("window") //The name of the window is mandatory. It specifies the "id" attribute of the widget.
.Title("Preliminary Report") //set the title of the window
.LoadContentFrom("Redir", "Reports") //define the Action and Controller name
.Visible(false)
.Iframe(true)
.Resizable()
.Width(750)
.Height(500)
.Scrollable(false)
.Draggable()
.Actions(a =>
{
a.Refresh();
a.Minimize();
a.Maximize();
a.Close();
})
)
<script>
function windowOpen(e) {
e.preventDefault();
var window = $("#window").data("kendoWindow");
window.open();
}
</script>
đoạn ReportController:
public ActionResult Redir()
{
return RedirectPermanent("../ASPReports/ReportForm.aspx");
}
ReportForm.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="~/ASPReports/ReportForm.aspx.cs" Inherits="MyApp.Reports.ReportForm"%>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="reportForm" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<rsweb:ReportViewer ID="mainReportViewer" runat="server" SizeToReportContent="true">
</rsweb:ReportViewer>
</div>
</form>
</body>
</html>
ReportForm.aspx.cs (code-behind):
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// credentials - could pull from config
var userid = "";
var password = "";
var domain = "";
IReportServerCredentials irsc = new CustomReportCredentials(userid, password, domain);
mainReportViewer.ServerReport.ReportServerCredentials = irsc;
//mainReportViewer.ServerReport.ReportServerUrl =
// new Uri(ConfigurationManager.AppSettings["ReportServerUrl"]);
mainReportViewer.ServerReport.ReportServerUrl =
new Uri("http://localhost/ReportServer");
mainReportViewer.ServerReport.ReportPath = "Path";
mainReportViewer.ProcessingMode = ProcessingMode.Remote;
mainReportViewer.ShowParameterPrompts = false;
mainReportViewer.ShowRefreshButton = false;
mainReportViewer.ShowWaitControlCancelLink = false;
mainReportViewer.ShowBackButton = false;
mainReportViewer.ShowCredentialPrompts = false;
var parametersCollection = new List<ReportParameter>();
//parametersCollection.Add(new ReportParameter("Snapshot", "##", false));
mainReportViewer.ServerReport.SetParameters(parametersCollection);
mainReportViewer.ServerReport.Refresh();
}
}
Nghĩ rằng giải pháp của bạn có thể được tìm thấy trong điều này có thể trùng lặp: [Làm cách nào để sử dụng điều khiển trình xem báo cáo trong chế độ xem asp.net mvc 3?] (Http: // stackoverflow.com/questions/6144513/how-can-i-sử dụng-a-reportviewer-control-in-an-asp-net-mvc-3-dao cạo-view) – Jeroen
không trùng lặp - các giao dịch bài đăng khác chỉ với các báo cáo địa phương. Tôi đã sửa đổi câu hỏi một cách thích hợp – Elsimer