"Open" option available when you're not on a file

7 posts, 0 answers
  1. Adam
    Adam avatar
    177 posts
    Member since:
    Oct 2012

    Posted 20 Jul 2011 Link to this post

    I'm not sure if this is a bug or intentional, but the Open option in the context menu is available even when you don't have a file selected. For example, if I right click in the open area in the file grid on the right, I can choose Open, which then attempts to open my path (with no file) using my file handler. I've written the following code to stop this from happening.

    if (item.get_url().lastIndexOf("/") == item.get_url().length - 1) {
                    alert('You must select a file to open.');
                } else {
                    var requestImage = "FileHandler.ashx?path=" + item.get_url();
                    document.location = requestImage;
                }
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 25 Jul 2011 Link to this post

    Hi Adam,

    By design, when right click occurs in the grid component and currently there is no item selected, RadFileExplorer automatically selects the first available item.

    I tried to reproduce the problem but to no avail. Could you please provide more detailed information on the specific scenario?
    • Which version of RadControls for ASP.NET AJAX and .NET Framework are used in the application?
    • Under which browser and its version the problem occurs?
    • Are you able to reproduce the problem on the live demos? If so, could you please provide the exact steps the need to be executed in order to reproduce the issue?
    • Could you please provide a simple fully runnable project reproducing the problem so we can investigate it further?

    Looking forward to hearing from you,
    Dobromir
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adam
    Adam avatar
    177 posts
    Member since:
    Oct 2012

    Posted 25 Jul 2011 Link to this post

    I am using the Q2 2011 with .NET 4.0. I am testing in IE 9.0.

    I cannot reproduce on live demos for the following reasons.
    -First Look - Has the Open option available when nothing is selected, however, when you click on it, nothing happens. I believe this is due to the fact that the Open option is being tied to popping up a preview window and not downloading of a file.
    -Application Scenarios->Filter files and download - I can reload the page fresh so nothing is selected, and then make the columns smaller so there is white space to the right that I can click on. When I right click in the open space and click Open, the first time it selected the first file, but doesn't download. The second time I click Open, it will then attempt to download the file. This is not what I am experiencing. In my instance, it doesn't select the first time for you and the white space that I'm clicking on is below all of the files and not to the right of it.
    -Server-Side API -> Custom File Content Provider - Doesn't provide the "Open" option.

    I won't be able to provide a working sample quickly, but could provide a video screen capture of the process and error in my project if that would be of assistance.

  5. Adam
    Adam avatar
    177 posts
    Member since:
    Oct 2012

    Posted 25 Jul 2011 Link to this post

    I think I've figured out the issue. It is correctly attempting to open the first item in the grid, however, the first item in the grid is a folder. When clicking open, it sends the folder to the file handler to be opened, which obviously won't work.

    Here is my new function which now correctly determines the folder or not.

    function OnClientFileOpen(sender, args) {
        var item = args.get_item();
         
        if (item.get_url().lastIndexOf("/") != item.get_url().length - 1) {
            args.set_cancel(true);
            var requestImage = "FileHandler.ashx" + item.get_url();
            document.location = requestImage;
        }
    }

    There is still one issue though. When you right click and click Open in the context menu, it does correctly select the first item in the grid, but it doesn't open it until you right click and click Open a second time. You can see this in the Live Demos as well.
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 27 Jul 2011 Link to this post

    Hi Adam,

    In the OnClientFileOpen handler you can check if the selected item is folder or file using the FileExplorerItem's isDirectory() client-side method, e.g.:
    function OnClientFileOpen(sender, args) {
        var item = args.get_item();
          
        if (!item.isDirectory()) {
            args.set_cancel(true);
            var requestImage = "FileHandler.ashx" + item.get_url();
            document.location = requestImage;
        }
    }

    Regarding the second issue, I tried to reproduce it but to no avail. Could you please provide the exact steps that need to be executed to replicate the problem? For your convenience I have prepared a video demonstrating my test, could you please see if I am doing something wrong?
    http://screencast.com/t/qarB0XEb25OB

    Greetings,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Adam
    Adam avatar
    177 posts
    Member since:
    Oct 2012

    Posted 27 Jul 2011 Link to this post

    Thanks. I will try isDirectory. I didn't see it in the documentation so I didn't think it existed.

    Here is a screen capture of the other issue I am talking about.

    http://screencast.com/t/tkLi6ZtnCMi

    I am using IE 9. This is a freshly loaded page of the First Look for the File Explorer. Nothing in the grid is selected. The first time I right click and click Open, it selected the folder. The second time I do it, it open the folder.
  8. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 01 Aug 2011 Link to this post

    Hi Adam,

    Thank you for the provided additional information and the video demonstrating the issue. It seems that the under InternetExplorer the item is not automatically selected on right click and if no item is selected the explorer is calling Open to the item selected in the treeview, which is the current folder. I have logged this issue in our database for further investigation.

    For the time being, you can examine if the Grid has selected item when the ClientFileOpen event occurs and cancel its further execution, e.g.:
    function OnClientFileOpen(explorer, args)
    {
        var grid = explorer.get_grid();
        var gridSelectedItem = grid.get_selectedItems();
        if (gridSelectedItem.length <= 0)
        {
            args.set_cancel(true);
        }
    }


    All the best,
    Dobromir
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017