how disable preview window when opening a file?

10 posts, 3 answers
  1. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 27 Mar 2016 Link to this post

    I am handling opening file by myself in browser, but this empty, small preview window also opens when file is double-clicked.

    how to disable, hide it or close it?   I don't want to disable fileopen event though.

    thank you

  2. Answer
    Vessy
    Admin
    Vessy avatar
    1621 posts

    Posted 28 Mar 2016 Link to this post

    Hi Wild,

    Cancelling the ClientFileOpen event of the control is actually the only way to prevent the showing of an empty preview window in FileExplorer. Can you elaborate on the exact reason you do not want to do that?

    Please note that even if you are canceling the event you can use all data from its arguments in order to open the file into separate window:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" EnableCopy="true" OnClientFileOpen="OnClientFileOpen">
        <Configuration ViewPaths="~/Images" DeletePaths="~/Images" UploadPaths="~/Images" />
    </telerik:RadFileExplorer>
    <script>
        function OnClientFileOpen(fileExplorer, args) {
            window.open(args.get_path(), "_blank");
            args.set_cancel(true);
        }
    </script>


    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 28 Mar 2016 in reply to Vessy Link to this post

    Hi Vessy,

    problem is I am opening this file from handler.ashx, I use custom database content provider.

    Opening my file like this:

    public void ProcessRequest(HttpContext context)
    {
    Context = context;
    if (context.Request.QueryString["path"] == null)
    {
        return;
    }
    string path = Context.Server.UrlDecode(Context.Request.QueryString["path"]);
    var item = DataServer.GetItem(path);
    if (item == null) return;

    System.Diagnostics.Process.Start(item["sourcePath"].ToString());
    }
     

     

    Any way to close that preview window in OnClientFileOpen?

     

    thanks

  4. Answer
    Vessy
    Admin
    Vessy avatar
    1621 posts

    Posted 31 Mar 2016 Link to this post

    Hi Wild,

    The approach you should use is the same, with the only difference that you will need to pass the item's path to your custom handler:
    function OnClientFileOpen(fileExplorer, args) {            
        window.open("Handler.ashx?path=" + args.get_path(), "_blank");
        args.set_cancel(true);
    }

    A similar approach (with a custom handler implementation) is demonstrated in the following online demo:
    http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx

    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 31 Mar 2016 Link to this post

    great!   the only problem is now OnClientFileOpen is called also when opening folders, and I don't want to

    why is folder treated as file?

    almost working :)

  6. Answer
    Vessy
    Admin
    Vessy avatar
    1621 posts

    Posted 01 Apr 2016 Link to this post

    Hi Wild,

    Yes, the Client FileOpen event is raised both for files and folders. You can determine the type of the opened item through its isDirectory() method:
    function OnClientFileOpen(fileExplorer, args) {
        if (!args.get_item().isDirectory()) {
            window.open("Handler.ashx?path=" + args.get_path(), "_blank");
            args.set_cancel(true);
        }
    }


    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  7. Wild
    Wild avatar
    10 posts
    Member since:
    Mar 2016

    Posted 01 Apr 2016 Link to this post

    thanks a lot, works fine. BTW if I wanted to use this built in small preview window, is there any way to resize it to be bigger?
  8. Vessy
    Admin
    Vessy avatar
    1621 posts

    Posted 05 Apr 2016 Link to this post

    Hi Wild,

    Yes, you can increase the size of the file preview window in FileExplore, but it will affect the size of all dialogs in the control as well. Please note that this can be done earlier in the Page_PreRenderComplete event handler:
    protected void Page_PreRenderComplete(object sender, EventArgs e)
    {
        RadFileExplorer1.WindowManager.Width = Unit.Pixel(1000);
        RadFileExplorer1.WindowManager.Height = Unit.Pixel(1000);
    }


    Regards,
    Vessy
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. CREMPF
    CREMPF avatar
    2 posts
    Member since:
    Feb 2016

    Posted 19 Dec 2016 in reply to Vessy Link to this post

    Where the Handler.ashx is located or how to create it please?
  10. Vessy
    Admin
    Vessy avatar
    1621 posts

    Posted 20 Dec 2016 Link to this post

    Hi,

    I have already answered your other ticket on the matter, for convenience I will paste my answer here as well:


    The Handler.ashx file use din the referred demo is available in our demos application, available for downloading form your account here:
    https://www.telerik.com/account/product-download?product=RCAJAX

    Once you install the application you will find the handler in a similar location (the version depends on the installed one):
    C:\Program Files (x86)\Telerik\UI for ASP.NET AJAX Q2 2016\Live Demos\FileExplorer\Examples\ApplicationScenarios\FilterAndDownloadFiles




    Regards,
    Vessy
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top