This is a migrated thread and some comments may be shown as answers.

FileBrowserController - Filter Not Working

3 Answers 125 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 24 May 2016, 03:50 PM

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")
  )
)

3 Answers, 1 is accepted

Sort by
0
Stamo Gochev
Telerik team
answered on 26 May 2016, 07:52 AM
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
0
Tim
Top achievements
Rank 1
answered on 26 May 2016, 04:08 PM

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

0
Stamo Gochev
Telerik team
answered on 27 May 2016, 05:20 AM
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
Tags
Editor
Asked by
Tim
Top achievements
Rank 1
Answers by
Stamo Gochev
Telerik team
Tim
Top achievements
Rank 1
Share this question
or