如何在kendo网格超链接中制作图像

时间:2016-04-04 11:49:47

标签: hyperlink kendo-ui kendo-grid kendo-asp.net-mvc

如何在需要指向文件的kendo网格超链接中制作图像。 Fileurl有一个位置URL,它将打开位于新选项卡中c文件夹中的文档。 我在这里给出了我的代码:

查看:

 @(Html.Kendo().Grid<MVCExample.Models.Data>()
                 .Name("PreviewGrid")
                 .Columns(columns =>
                 {
                     columns.Template(e => e.FileUrl).ClientTemplate("<img src='../../Images/pdficon.png'/>").Title("").Width(10);
                     columns.Bound(e => e.PName).Title("ReportName").Width(50).HeaderHtmlAttributes(new { @style = "font-weight:bold" });
                     //columns.Bound(e => e.FileUrl).Title("FileName").Width(200).HeaderHtmlAttributes(new { @style = "font-weight:bold" });

                 })
                 .HtmlAttributes(new { style = "width:800px" })
                 .Scrollable()
                 .DataSource(dataSource => dataSource
                     .Ajax()
                     .PageSize(20)
                     .Batch(true)
                     .ServerOperation(false)
                     .Model(model =>
                      {
                          model.Field(p => p.Name).Editable(false);
                          model.Field(p => p.FileDate).Editable(false);
                      }).Read(read => read.Action("ReadData", "Home").Data("GetFilterData"))

                      )
                .Pageable(pager => pager.PageSizes(new int[] { 25, 50, 100, 200 }))
                .Sortable()
                .Scrollable(scrollable => scrollable.Enabled(false))
    )

控制器:

IList<DataDto1> p1 = this.mycodee.GetData();
            IList<DataDto> p2 = this.mycode.GetDataFiles();
            string url = EnvSettingsTools.FIRArchivePath.ToString();
             var data = from s in p1
                               where s.pId == 5//Convert.ToInt32(filterBydesk)
                               join e in p2
                               on s.PId equals e.PId
                               where e.PDate.Date == filterByDate
                               where e.PortfolioId ==1// Convert.ToInt32(filterByportfolio)
                               select new File
                               {
                                   PName = s.pName,
                                   FileUrl = url+""+ e.FileName+".pdf"
                               };

1 个答案:

答案 0 :(得分:0)

我解决了,

@(Html.Kendo().Grid<MVCExample.Models.Data>()
                 .Name("PreviewGrid")
                 .Columns(columns =>
                 {
                     
                     columns.Bound(e => e.PortfolioName).Title("ReportName").HeaderHtmlAttributes(new { @style = "font-weight:bold" });
                     columns.Template(e => e.FileUrl).ClientTemplate("<a target='_blank' href='file:///#:data.FileUrl#'><img src='/Areas/Tools/Images/iconpdf.gif'/></a>").Title("");

                 })
)

感谢您的支持