OnClientCopy get_item null

6 posts, 1 answers
  1. Jed
    Jed avatar
    16 posts
    Member since:
    Apr 2009

    Posted 10 Sep 2012 Link to this post

    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
  2. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 11 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jed
    Jed avatar
    16 posts
    Member since:
    Apr 2009

    Posted 11 Sep 2012 Link to this post

    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
  5. Jed
    Jed avatar
    16 posts
    Member since:
    Apr 2009

    Posted 13 Sep 2012 Link to this post

    Any solutions?

    Thanks,

    Jed
  6. Answer
    Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 14 Sep 2012 Link to this post

    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.
  7. Jed
    Jed avatar
    16 posts
    Member since:
    Apr 2009

    Posted 14 Sep 2012 Link to this post

    That works great. Thanks!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017