|
Rank: Newbie Groups: Member
Joined: 5/25/2010 Posts: 5
|
I want the user to be able to download a selected file that has been previously uploaded.
Does the file explorer support this functionality? and if not can the downloader tool be used within the File Explorer tool.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Yes. You can use the Downloader together with FileExplorer but not within the file list. For example, it is not possible to add a "Download" column next to the "File Name" column. However it is possible to add a "Download" button somewhere outside of the file list (for example, inside the "Preview" area) and dynamically show/hide that button depending on whether the current selected file can be downloaded.
In order to do this, you will need to first customize the FileExplorer's LayoutTemplate to put your download button in. Then handle the FileExplorer's ClientSideOnFileSelected to update your download button and the Downloader control accordingly. Because your ClientSideOnFileSelected handler is a JavaScript function and you can only update the Downloader's Url property on the server side, you will also need to trigger an AJAX callback from your client side handler so that you can call your server side code to update the Downloader's Url property. Once the property is updated, the Downloader should be ready to download.
Hope this helps. Please feel free to let us know if you have any more questions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2010 Posts: 5
|
"In order to do this, you will need to first customize the FileExplorer's LayoutTemplate to put your download button in. Then handle the FileExplorer's ClientSideOnFileSelected to update your download button and the Downloader control accordingly. Because your ClientSideOnFileSelected handler is a JavaScript function and you can only update the Downloader's Url property on the server side, you will also need to trigger an AJAX callback from your client side handler so that you can call your server side code to update the Downloader's Url property. Once the property is updated, the Downloader should be ready to download."
I just added the downloader code similar to the uploader in the File Explorer. That is <div id="Div1" style="display:none; height:55px"> <eo:Downloader runat="server" id="Downloader2" downloadButtonID="Button3"></eo:Downloader> <asp:Button Runat="server" ID="Button3" Text="View"></asp:Button> </div> And in the tool bar beside the Upload item added an download item.
I just tried to compile this and I got this error. System.Exception: Either 'File' property or 'Url' property must be set for Downloader 'Downloader2' when DynamicContents is set to false.
Also could you please specify what I need to do for"Then handle the FileExplorer's ClientSideOnFileSelected to update your download button and the Downloader control accordingly"
Thanks, Sanchi
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You will always need to set the Downloader's Url property --- even before a file is selected. You can set it to a dummy Url but then set the control's Visible to false. By "handle the FileExplorer's ClientSideOnFileSelected to update your download button" I meant several things: 1. Handle the FileExplorer's ClientSideOnFileSelected event. It will be something like this:
Code: HTML/ASPX
<eo:FileExplorer ClientSideOnFileSelected="your_handler" ....>
...
</eo:FileExplorer>
Code: JavaScript
function your_yhandler(fe)
{
//Get the selected file
var selectedFile = fe.getSelectedFile();
//Do whatever else you need to do.....
.....
}
You can find more information about our client side API here: http://doc.essentialobjects.com/library/1/clientapi_howto.aspx2. Update your download button inside your handler. For example, you may want to set "Div1"'s style.display = "block"; 3. Trigger an AJAX call to update the Downloader's Url property. You can use our CallbackPanel or MS UpdatePanel to do that (you will need to put the downloader inside the CallbackPanel or UpdatePanel). Please see the CallbackPanel documentation or MS UpdatePanel documentation for how to do that. If you have any questions with our CallbackPanel let us know; Once you implement all those, then when user selects a file, your handler function will be called. Your code inside the handler would then updates your download button and the downloader control's Url based on the selected file. Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2010 Posts: 5
|
Thanks for the reply.
Back again this morning with more questions.
I got the downloader URL to be initialized with the user selected value.
The only thing remaining is the working of the download button inside the Fileuploader.
I have added download ToolBarItem next to the upload file ToolBarItem. But the problem is that the download ToolBarItem is in disabled mode. How do I enable it and how do I make it working when the user selects it.
Thanks, Sanchi
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, All the extra toolbar buttons will be initially disabled. You can enable/disable it with JavaScript when you need to. The code will be something like this:
Code: JavaScript
var toolBar = eo_GetObject("ToolBar1");
var toolBarItem = toolBar.getItem(itemIndex);
toolBarItem.setDisabled(false);
You will need to: 1. Replace "ToolBar1" with the ID of your ToolBar control; 2. Replace itemIndex with the index of your download button; In order to respond the toolbar item client event, you will need to handle the ToolBar's ClientSideOnItemClick event. It will be again a JavaScript handler:
Code: JavaScript
function toolbar_item_click(toolBar, toolBarItem)
{
if (toolBarItem.getCommandName() == "Download")
{
//Trigger your downloader
var downloader = eo_GetObject("Downloader1");
downloader.start();
}
}
Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2010 Posts: 5
|
Thansk a lot!
That worked perfectly.
Few more clarificatios.
1. I am using the demo versions. And I noticed that the date picker does not work in this version. Could you please let me know if it does work in the full version I buy, then what would the column in the grid display. What will the datepicker actually do?
2. Can I resize the whole File uploader tool? I tried it but the check box selection does not work.
Thanks, Sanchi
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Glad that it works for you. As to your questions: 1. All controls , including the DatePicker control should work fine in demo version. Without a license the control will randomly render a license warning message and also eventually expires. You can see what the DatePicker does here: http://demo.essentialobjects.com/default.aspx?path=CalendarIt does not have anything to do with your FileExplorer/Downloader scenario though. So I am not sure what you mean by "what would the column in the Grid display". 2. I am not sure what you mean by "resize the file uploader tool" either. If you meant resizing in code, then yes (because everything is controled by LayoutTemplate). If you meant resizing by user dragging the mouse, then no. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 5/25/2010 Posts: 5
|
1. It does not have anything to do with your FileExplorer/Downloader scenario though. So I am not sure what you mean by "what would the column in the Grid display".
-- I actually wanted to know the use of datepicker? -- Will there be a column to display the created date or the modified date of the file.
Few more... 3. Is it possible to set the selected folder/File as one of the child folder/File when the page loads? Basically I want the FileExplorer to be prepopulated with the values than for the user to browse to the folder.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
DatePicker is a totally separate control that is rendered as a textbox and a drop down button. When user clicks the drop down button it opens a calendar drop down to let user to pick a date. It is an input control. You can take a look of the samples and documentations to see what DatePicker does.
There is no way to display create date or modified date of the file. We could add it but the main issue here being time zone issue because the file will be based on server time but your user's time zone can be different.
There is no way to prepopulate the selected folder for the FileExplorer control either. It always automatically select the root folder. However because FileExplorer control is implemented with TreeView, ToolBar, Grid, Splitter and Uploader control, so you can always implement any features you want to with those controls separately. That way you basically implement a populate on demand TreeView and Grid inside an AJAX Panel. It will be some extra coding but you should be able to implement it anyway you want. For example, you can add the datetime columns as well.
Thanks!
|
|