文件下载没有出现在弹出对话框的剑道窗口中 [英] File download not appearing in pop-up dialog kendo window

查看:113
本文介绍了文件下载没有出现在弹出对话框的剑道窗口中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



美好的一天...



我想问或是这是kendow窗口上的错误,或者可能是我的代码中缺少某些内容。

我正在尝试下载不同类型的文件(.zip,pdf.xlsx,docx等)。

但是当我试图点击下载链接(附件名称链接)时,数据试图在kendo窗口上打开为垃圾。

这个文件是一个字节数据类型来自SQL Server数据库..

我在弹出对话框kendo窗口中使用它,里面有一个kendo网格。



这是我的代码如下:



Razor:



 <   pre  >  @(Html.Kendo ()。Grid(Of SPIMS.ViewModel.ProjectViewModel.StatusAndLockingEntity)()_ 
.Name(gridProjectAttachment)_
.Columns(Sub(c)
c.Bound(Function(p)p.ID).Visible(False)
c.Bound(Function(p)p.AttachmentName).Width(300).HtmlAttributes(New with {{class =gridContentLeft }。标题(附件)_
.ClientTemplate(< a < span class =code-attribute> href =' javascript:statusAndLocking_DownloadFile(+#= ID#+)' > +#= AttachmentName#+ < / a >
c.Bound(Function(p)p.FileSize).Width(100).HtmlAttributes(New With {.class =gridBodyAttribute})。Title(File Size)
End Sub) _
.Sortable(函数(排序)排序.AllowUnsort(真))_
.Filterable()_
.Scrollable()_
.HtmlAttributes(新的{.style =height:200px; width:470px;})_
.DataSource(Sub(d)
d.Ajax()_
.PageSize(Session(LocalConstant.Ses_GridPageSize))_
.Model(Sub(model)model.Id(Function (p)p.ID))_
。事件(Sub(e)
e.Error(grid_error_handler)
End Sub)_
.ServerOperation(False)_
。读取(函数(读取)read.Action(ProjectAttachment_Read,StatusAndLocking))
End Sub)_
.Pageable(功能(可分页)可分页_
。刷新(True)_
.PageSizes(True)_
.ButtonCount(会话(本地) Constant.Ses_GridButtonCount))))









这是javascript代码:







  function  statusAndLocking_DownloadFile(projectAttachmentID){
var windowAttachment = #windowAttachment;
调试器;
$(windowAttachment).kendoWindow();
var dialog = $(windowAttachment).data( kendoWindow);
dialog.refresh(
{
url: / StatusAndLocking / GetFileByProjectAttachmentID
data:{id:projectAttachmentID}
});
}





这是控制器:





 ' 下载文件 
功能 GetFileByProjectAttachmentID( ByVal id As 整数 As FileContentResult
Dim _repoProject 作为 ProjectRepository
Dim _projectAttachment 作为 ProjectViewModel.StatusAndLockingEntity
Dim fileData 作为 字节()= 没什么
Dim fileName 作为 字符串 = String .Empty

_projectAttachment = _repoProject.StatusAndLocking_GetFileByProjectAttachmentID(id)

如果 _projectAttachment < span class =code-keyword> IsNot Nothing 然后
fileData = _projectAttachment.SystemFile
fileName = _projectAttachment.AttachmentName


结束 如果

返回文件(fileData,System.Net.Mime.MediaTypeNames.Application.Octet,fileName)
< span class =code-keyword>结束 功能







提前感谢您的帮助......

解决方案

(windowAttachment).kendoWindow();
var dialog =


(windowAttachment).data( kendoWindow);
dialog.refresh(
{
url: / StatusAndLocking / GetFileByProjectAttachmentID
data:{id:projectAttachmentID}
});
}





这是控制器:





 ' 下载文件 
功能 GetFileByProjectAttachmentID( ByVal id As 整数 As FileContentResult
Dim _repoProject 作为 ProjectRepository
Dim _projectAttachment 作为 ProjectViewModel.StatusAndLockingEntity
Dim fileData 作为 字节()= 没什么
Dim fileName 作为 字符串 = String .Empty

_projectAttachment = _repoProject.StatusAndLocking_GetFileByProjectAttachmentID(id)

如果 _projectAttachment < span class =code-keyword> IsNot Nothing 然后
fileData = _projectAttachment.SystemFile
fileName = _projectAttachment.AttachmentName


结束 如果

返回文件(fileData,System.Net.Mime.MediaTypeNames.Application.Octet,fileName)
< span class =code-keyword>结束 功能







提前感谢您的帮助......


我解决了...我刚刚更改了我的javascript函数





  function  statusAndLocking_DownloadFile(projectAttachmentID){
var finUrl = / StatusAndLocking / GetFileByProjectAttachmentID / + projectAttachmentID;
var win = window .open(finUrl);
win.focus();
}


Hi to all,

Great day...

I would like to ask or is this a bug on kendow window or may be there's something missing on my code.
I'm trying to download a different types of file (.zip, pdf. xlsx, docx, etc).
But when I'm try to click the download link (attachment name link), the data is trying to open on kendo window as garbage.
This file is a byte data type came from SQL Server database..
I use this on pop-up dialog kendo window where there's a kendo grid inside of it.

Here's my code below:

Razor:

<pre>@(Html.Kendo().Grid(Of SPIMS.ViewModel.ProjectViewModel.StatusAndLockingEntity)() _
             .Name("gridProjectAttachment") _
             .Columns(Sub(c)
                              c.Bound(Function(p) p.ID).Visible(False)
                              c.Bound(Function(p) p.AttachmentName).Width(300).HtmlAttributes(New With {.class = "gridContentLeft"}).Title("Attachment") _
                                     .ClientTemplate("<a href='javascript:statusAndLocking_DownloadFile(" + "#=ID#" + ")'>" + "#=AttachmentName#" + "</a>")
                              c.Bound(Function(p) p.FileSize).Width(100).HtmlAttributes(New With {.class = "gridBodyAttribute"}).Title("File Size")
                      End Sub) _
             .Sortable(Function(sorting) sorting.AllowUnsort(True)) _
             .Filterable() _
             .Scrollable() _
             .HtmlAttributes(New With {.style = "height:200px;width:470px;"}) _
             .DataSource(Sub(d)
                                 d.Ajax() _
                                 .PageSize(Session(LocalConstant.Ses_GridPageSize)) _
                                 .Model(Sub(model) model.Id(Function(p) p.ID)) _
                                 .Events(Sub(e)
                                                 e.Error("grid_error_handler")
                                         End Sub) _
                                 .ServerOperation(False) _
                                 .Read(Function(read) read.Action("ProjectAttachment_Read", "StatusAndLocking"))
                         End Sub) _
         .Pageable(Function(pageable) pageable _
         .Refresh(True) _
         .PageSizes(True) _
         .ButtonCount(Session(LocalConstant.Ses_GridButtonCount))))





Here's the javascript code:




function statusAndLocking_DownloadFile(projectAttachmentID) {
       var windowAttachment = "#windowAttachment";
       debugger;
       $(windowAttachment).kendoWindow();
       var dialog = $(windowAttachment).data("kendoWindow");
       dialog.refresh(
           {
               url: "/StatusAndLocking/GetFileByProjectAttachmentID",
               data: { id: projectAttachmentID }
           });
   }



Here's the controller:



'Download File
  Function GetFileByProjectAttachmentID(ByVal id As Integer) As FileContentResult
      Dim _repoProject As New ProjectRepository
      Dim _projectAttachment As New ProjectViewModel.StatusAndLockingEntity
      Dim fileData As Byte() = Nothing
      Dim fileName As String = String.Empty

      _projectAttachment = _repoProject.StatusAndLocking_GetFileByProjectAttachmentID(id)

      If _projectAttachment IsNot Nothing Then
          fileData = _projectAttachment.SystemFile
          fileName = _projectAttachment.AttachmentName


      End If

      Return File(fileData, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)
  End Function




Thank you in advance for your kind help...

解决方案

(windowAttachment).kendoWindow(); var dialog =


(windowAttachment).data("kendoWindow"); dialog.refresh( { url: "/StatusAndLocking/GetFileByProjectAttachmentID", data: { id: projectAttachmentID } }); }



Here's the controller:



'Download File
  Function GetFileByProjectAttachmentID(ByVal id As Integer) As FileContentResult
      Dim _repoProject As New ProjectRepository
      Dim _projectAttachment As New ProjectViewModel.StatusAndLockingEntity
      Dim fileData As Byte() = Nothing
      Dim fileName As String = String.Empty

      _projectAttachment = _repoProject.StatusAndLocking_GetFileByProjectAttachmentID(id)

      If _projectAttachment IsNot Nothing Then
          fileData = _projectAttachment.SystemFile
          fileName = _projectAttachment.AttachmentName


      End If

      Return File(fileData, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)
  End Function




Thank you in advance for your kind help...


I solved it... I just changed my javascript function


function statusAndLocking_DownloadFile(projectAttachmentID) {
        var finUrl = "/StatusAndLocking/GetFileByProjectAttachmentID/" + projectAttachmentID;
        var win = window.open(finUrl);
        win.focus();
    }


这篇关于文件下载没有出现在弹出对话框的剑道窗口中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆