如何在Kendo网格上显示图像,而不是实际路径?

时间:2017-08-29 11:55:10

标签: javascript c# asp.net-mvc kendo-grid

我正在尝试从服务器(网络文件夹)将图像加载到Kendo网格中。首先,我已将图像上传到(网络文件夹),它工作正常。

现在我必须阅读所有图像并将其显示在网格中(剑道)。现在的挑战是网格只加载网格上图像的所有实际路径。

如何显示网络文件夹中的图像,而不是图像的路径?

它加载: \ 00.00.00.0000 \ Folder \ Settings \ BackgroundImage \ 20170802_173645.jpg

阅读图片

public ActionResult ReadBackgroundImage([DataSourceRequest]DataSourceRequest request) 
    {
        try
        {
            List<SettingsModel> list = new List<SettingsModel>();

            //Getting all the images from DirectoryInfo
            var directory = new DirectoryInfo(Filelocation);
            var allowedExtensions = new string[] { ".jpg", ".png" };

            var imageFiless = from file in directory.EnumerateFiles("*", SearchOption.AllDirectories)
                              where allowedExtensions.Contains(file.Extension.ToLower())
                              select file;

            foreach (var file in imageFiless)
            {
                SettingsModel img = new SettingsModel();
                img.ImageUrl = file.DirectoryName;
                img.PictureName = file.FullName;
                list.Add(img);
            }
            return Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }
        catch (Exception ex)
        {
            return Content("", ex.ToString());
        }
    }

查看和剑道网格

@(Html.Kendo().Grid<TTAF.Portal.Parts.Web.Models.SettingsModel>()
                            .Name("Grid")
                            .Columns(columns =>
                            {
                            columns.Bound(client => client.PictureName).ClientTemplate("#=PictureName#");

                            columns.Bound(x => x.IsSelected).Template(@<text></text>).ClientTemplate("<input id='chkId' name'chkbox' type='checkbox' #= IsSelected ? checked='checked':'' # class='checkbox' onClick='ValidateMoreClick()' />").Title("Selected Image");

                            }))

0 个答案:

没有答案