Asp.net mvc MVC中使用剑道网格的PDF

Asp.net mvc MVC中使用剑道网格的PDF,asp.net-mvc,pdf,kendo-ui,kendo-grid,Asp.net Mvc,Pdf,Kendo Ui,Kendo Grid,我使用剑道格网。在该网格中,第一列是超链接列。如果单击每个超链接,则超链接的选定文本应传递给控制器操作。该超链接文本实际上是一个pdf文件名。因此,如果在网格上单击一个文件名,那么同一个文件应该在同一个页面本身的标记中打开。网格和用于查看PDf的标记都位于同一页面中。如何做到这一点 剑道网格://这个网格将在Home.cshtml中,而且我把它分成了两部分。一个网格将向左浮动,另一个网格将向右浮动,如下所示 *************************网格****************

我使用剑道格网。在该网格中,第一列是超链接列。如果单击每个超链接,则超链接的选定文本应传递给控制器操作。该超链接文本实际上是一个pdf文件名。因此,如果在网格上单击一个文件名,那么同一个文件应该在同一个页面本身的标记中打开。网格和用于查看PDf的标记都位于同一页面中。如何做到这一点

剑道网格://这个网格将在Home.cshtml中,而且我把它分成了两部分。一个网格将向左浮动,另一个网格将向右浮动,如下所示


*************************网格***************************

 @(Html.Kendo().Grid<SearchEmailHistoryGridModel>()
            .Name("EmailSearchGrid")
            .Columns(columns =>
            {

                columns.Bound(p => p.ExtractId).Visible(false);
                columns.Bound(p => p.FileName).Title("File Name");
                columns.Bound(p => p.TemplateName).Title("Template");
                columns.Bound(p => p.CentreName).Title("Centre");
                columns.Bound(p => p.LeaseId).Title("Lease ID");
                columns.Bound(p => p.Unit).Title("Unit").Width("80px");
                columns.Bound(p => p.Occupant).Title("Occupant");
                columns.Bound(p => p.ContactName).Title("Contact");
                columns.Bound(p => p.Attachment).Title("Attachment").ClientTemplate("# if(data.Attachment!=null) {# <div style='cursor: hand;'><a class='gridLink' href='\\#' id='slpitLink'  title='Download #:Attachment#' onclick=\"DownloadFile(#:ExtractId#,'#:FileName#','#:Attachment#'); return false;\">View</a></div> #}#");
                columns.Bound(p => p.EmailAddress).Title("Email").Width("150px");
                columns.Bound(p => p.EmailSent).Title("Email Sent").Visible(false);
                columns.Bound(p => p.FirstSentDate).Title("Date Sent").Width("85px");
                columns.Bound(p => p.SentBy).Title("Sent By").Width("85px");
                columns.Bound(p => p.Delivered).Title("Delivered").Width("85px");
                columns.Bound(p => p.Read).Title("Read").Width("70px");
                columns.Bound(p => p.Exception).Title("Error").ClientTemplate("# if(data.Exception=='Yes') {# <a style='color:\\#94BB27; text-decoration:none; cursor:help' title='#:data.ExceptionDescription#'>Yes</a> #} else {# <label>No</label>  #}#").Width("60px");



                columns.Command(command =>
                {
                    command.Custom("Resend").Click("ResendEmail").HtmlAttributes(new { title = "Resend Email" });
                    command.Custom("Forward").Click("SendForwardEmail").HtmlAttributes(new { title = "Forward Email" });
                }).Title("Action");


            })
            .Events(e => e.DataBound("onEmailSearchDataBound"))
            .Pageable(pageable => pageable
                    .Refresh(true)
                    .PageSizes(true)
                    .PageSizes(new int[] { 5, 10, 20,50 })
                    .ButtonCount(5)
                    )
            .Filterable()                
            .Scrollable()
            .HtmlAttributes(new { style = "height:650px;" })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Events(events => events.Error("error_handler"))  
                .Model(model =>
                    {
                        model.Id(c => c.ExtractId);

                    })   
                .Read(read => read.Action("ReadEmailHistory", "EmailManagement").Data("GetSearchFilterData")) 

            )

        )
  //Download File
          function DownloadFile(extractId,folder,fileNameParam) {


              $.post('@Url.Action("DownloadFile", "Correspondence")', { extractId: extractId, folder: folder, fileName: fileNameParam })
                .done(function (data) {
                    if (data.url == null) {

                        showMessage(data);
                    }
                    else {

                        $("body").append("<iframe src='" + data.url + "' style='display: none;'></iframe>");
                    }

                });

          }
   //Download File
    [HttpPost]
    [FilterSessionExpire]
    public ActionResult DownloadFile(int extractId,string folder, string fileName)
    {

        var filePath = Path.Combine(ConfigurationManager.AppSettings["EcorsSplitFilePath"],folder, fileName); //in folder level

        if (System.IO.File.Exists(filePath))
        {
            //return file link
            return Json(new { url = Url.Action("DownloadFileActual", "Correspondence", new { folder = folder, fileName = fileName }) }, JsonRequestBehavior.AllowGet);
        }

        //else return error
        return Json("File:" + fileName + " Not found.", JsonRequestBehavior.AllowGet);
    }


   //Actual Download File 
    public ActionResult DownloadFileActual(string folder, string fileName)
    {
        const string contentType = "application/pdf";
        var filePath = Path.Combine(ConfigurationManager.AppSettings["EcorsSplitFilePath"], folder, fileName); //in folder level
        return File(filePath, contentType, fileName);


    }

我正在努力将这部分需求可视化为“在标签中打开”和“标签查看PDf”。你能详细说明一下吗。
  //Download File
          function DownloadFile(extractId,folder,fileNameParam) {


              $.post('@Url.Action("DownloadFile", "Correspondence")', { extractId: extractId, folder: folder, fileName: fileNameParam })
                .done(function (data) {
                    if (data.url == null) {

                        showMessage(data);
                    }
                    else {

                        $("body").append("<iframe src='" + data.url + "' style='display: none;'></iframe>");
                    }

                });

          }
   //Download File
    [HttpPost]
    [FilterSessionExpire]
    public ActionResult DownloadFile(int extractId,string folder, string fileName)
    {

        var filePath = Path.Combine(ConfigurationManager.AppSettings["EcorsSplitFilePath"],folder, fileName); //in folder level

        if (System.IO.File.Exists(filePath))
        {
            //return file link
            return Json(new { url = Url.Action("DownloadFileActual", "Correspondence", new { folder = folder, fileName = fileName }) }, JsonRequestBehavior.AllowGet);
        }

        //else return error
        return Json("File:" + fileName + " Not found.", JsonRequestBehavior.AllowGet);
    }


   //Actual Download File 
    public ActionResult DownloadFileActual(string folder, string fileName)
    {
        const string contentType = "application/pdf";
        var filePath = Path.Combine(ConfigurationManager.AppSettings["EcorsSplitFilePath"], folder, fileName); //in folder level
        return File(filePath, contentType, fileName);


    }