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

OnClientCopy get_item null

5 Answers 92 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Jed
Top achievements
Rank 1
Jed asked on 10 Sep 2012, 03:41 PM
Hi,

   I would like to log the source file and path being copied to the destination directory. When using the OnClientCopy I do get a value for the RadFileExplorerEventArgs get_newPath() but not for the get_item. Is there a way to get this value?

Thanks!

Jed

5 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 11 Sep 2012, 03:05 PM
Hi Jed,

The get_item() method of the OnClientCopy event's arguments returns null instead of a reference to the copied object, because this method is nor supported for this client event.

You could access the copied element using the get_selectedElement() method:
function OnClientCopy(explorer, args) {
    var newPath = args.get_newPath();
    var selectedItem = explorer.get_selectedItem();
 
    //If you want to log only the name of the file
    //var selectedItemName = explorer.get_selectedItem().get_name();
}

As a small token of our gratitude for your efforts I have updated your Telerik points.

All the best,
Vesi
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jed
Top achievements
Rank 1
answered on 11 Sep 2012, 06:44 PM
Hi Vesi,

   Unfortunately I've tried this and what happens is that the last selected value is captured as opposed to the item that is being copied. For example, let's say I have a root directory named "voiceFiles" and a subdirectory in the root named "english" and a file under the voiceFiles directory named "test.wav".

-voiceFiles/
    |-english/
    |-test.wav

If right click on the test.wav file and click "copy" and then click on the "english" directory and right click "paste" the explorer.get_selectedItem().get_name() will equal "english" and not the test.wav value. This will be a problem whenever the user will need to navigate to any other directory structure in the file system. Any ideas?

Thanks,

Jed
0
Jed
Top achievements
Rank 1
answered on 14 Sep 2012, 02:12 AM
Any solutions?

Thanks,

Jed
0
Accepted
Dobromir
Telerik team
answered on 14 Sep 2012, 10:35 AM
Hi Jed,

As a possible solution to this case I would suggest you to use additional variable to store the copied items and access them in the ClientCopy client-side event. To get the copied items you should handle the FileList context menu's clicked event and get the explorer's selected items, e.g.:
<telerik:RadFileExplorer ID="fileExplorer" runat="server" EnableCopy="true" OnClientLoad="explorerLoad" OnClientCopy="explorerCopy">
    <Configuration ViewPaths="~/ROOT" DeletePaths="~/ROOT" UploadPaths="~/ROOT" />
</telerik:RadFileExplorer>
 
<script type="text/javascript">
    var copiedItems = [];
    function explorerLoad(explorer)
    {
        explorer.get_gridContextMenu().add_itemClicked(function(sender, args){
            if(args.get_item().get_value() == "Copy")
            {
                copiedItems = explorer.get_selectedItems();
            }
        })
    }
 
    function explorerCopy(explorer, args)
    {
        //access the copied items through copiedItems variable
    }
</script>

In addition, we have logged this ClientSide event for improvements but I cannot provide firm estimate when these improvements will be available.

Greetings,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jed
Top achievements
Rank 1
answered on 14 Sep 2012, 05:56 PM
That works great. Thanks!
Tags
FileExplorer
Asked by
Jed
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Jed
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or