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

how disable preview window when opening a file?

9 Answers 84 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Wild
Top achievements
Rank 1
Wild asked on 28 Mar 2016, 02:06 AM

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

9 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 28 Mar 2016, 12:23 PM
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.
0
Wild
Top achievements
Rank 1
answered on 28 Mar 2016, 08:15 PM

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

0
Accepted
Vessy
Telerik team
answered on 31 Mar 2016, 03:17 PM
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.
0
Wild
Top achievements
Rank 1
answered on 31 Mar 2016, 10:57 PM

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

0
Accepted
Vessy
Telerik team
answered on 01 Apr 2016, 03:37 PM
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.
0
Wild
Top achievements
Rank 1
answered on 02 Apr 2016, 01:17 AM
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?
0
Vessy
Telerik team
answered on 05 Apr 2016, 06:16 PM
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.
0
CREMPF
Top achievements
Rank 1
answered on 19 Dec 2016, 04:01 PM
Where the Handler.ashx is located or how to create it please?
0
Vessy
Telerik team
answered on 20 Dec 2016, 09:28 AM
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.
Tags
FileExplorer
Asked by
Wild
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Wild
Top achievements
Rank 1
CREMPF
Top achievements
Rank 1
Share this question
or