FileBrowserController - Filter Not Working

4 posts, 0 answers
  1. Tim
    Tim avatar
    12 posts
    Member since:
    Nov 2012

    Posted 24 May Link to this post

    I added a Kendo Editor along with the FileBrowserController and ImageBrowserController per the example - File and Image Browser. My problem is the filter prevents all files from displaying. If the filter is in place I can't see any files in the directory even though there are files there with the correct extensions. If I comment out the filter I can see the files. I can see the Filter value getting set correctly in the debugger. Not sure how to fix this.

    public class FileBrowserController : EditorFileBrowserController
    {
        private const string contentFolderRoot = "~/Content/";
        private const string prettyName = "Documents";
     
        /// <summary>
        /// Gets the base paths from which content will be served.
        /// </summary>
        public override string ContentPath
        {
            get
            {
                return CreateUserFolder();
            }
        }
     
        /// <summary>
        /// Gets the valid file extensions by which served files will be filtered.
        /// </summary>
        public override string Filter
        {
            get
            {
                return "*.txt, *.doc, *.docx, *.xls, *.xlsx, *.ppt, *.pptx, *.jpg, *.jpeg, *.gif, *.png, *.pdf";
            }
        }
     
        private string CreateUserFolder()
        {
            var virtualPath = Path.Combine(contentFolderRoot, "Clients", prettyName);
     
            var path = Server.MapPath(virtualPath);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return virtualPath;
        }
    }

    @(Html.Kendo().Editor()
          .Name("editor")
          .HtmlAttributes(new { style = "height:440px" })
          .Tools(tools => tools.Clear().InsertImage().InsertFile())
          .Value(@<text>
            <p>
                Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
                In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists,
                and image handling. The widget <strong>outputs identical HTML</strong> across all major browsers, follows
                accessibility standards and provides API for content manipulation.
            </p>
            <p>Features include:</p>
            <ul>
                <li>Text formatting & alignment</li>
                <li>Bulleted and numbered lists</li>
                <li>Hyperlink and image dialogs</li>
                <li>Cross-browser support</li>
                <li>Identical HTML output across browsers</li>
                <li>Gracefully degrades to a <code>textarea</code> when JavaScript is turned off</li>
            </ul>
            <p>
                Read <a href="http://docs.telerik.com/kendo-ui">more details</a> or send us your
                <a href="http://www.telerik.com/forums">feedback</a>!
            </p>
        </text>)
     .ImageBrowser(imageBrowser => imageBrowser
        .Image("~/Content/Clients/Images/{0}")
        .Read("Read", "ImageBrowser")
        .Create("Create", "ImageBrowser")
        .Destroy("Destroy", "ImageBrowser")
        .Upload("Upload", "ImageBrowser")
        .Thumbnail("Thumbnail", "ImageBrowser"))
     .FileBrowser(fileBrowser => fileBrowser
         .File("~/Content/Clients/Documents/{0}")
         .Read("Read", "FileBrowser")
         .Create("Create", "FileBrowser")
         .Destroy("Destroy", "FileBrowser")
         .Upload("Upload", "FileBrowser")
      )
    )

  2. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 26 May Link to this post

    Hi Tim,

    You need to separate the file extensions by a comma (and not by a comma and space):
    public override string Filter
    {
        get
        {
            return "*.txt,*.doc,*.docx,*.xls,*.xlsx,*.ppt,*.pptx,*.jpg,*.jpeg,*.gif,*.png, *.pdf";;
        }
    }
    I agree that this is kind of restrictive, so I have logged an item that you can monitor:

    https://github.com/telerik/kendo-ui-core/issues/1717

    Regards,
    Stamo Gochev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Kendo UI is VS 2017 Ready
  4. Tim
    Tim avatar
    12 posts
    Member since:
    Nov 2012

    Posted 26 May in reply to Stamo Gochev Link to this post

    Thanks Stamo. Just so you know, the MVC example on the Kendo demo site has spaces. 

    http://demos.telerik.com/aspnet-mvc/editor/imagebrowser

    Tim

  5. Stamo Gochev
    Admin
    Stamo Gochev avatar
    157 posts

    Posted 27 May Link to this post

    Hi Tim,

    Thanks for this mention! When we update the implementation, the demo will work OK.

    Regards,
    Stamo Gochev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
Kendo UI is VS 2017 Ready