Issue changing folders from RadGrid selection

6 posts, 0 answers
  1. Paul
    Paul avatar
    5 posts
    Member since:
    Oct 2016

    Posted 21 Oct Link to this post

    I have noticed some very peculiar behavior when setting the folder of the FileExplorer from a record selected on a RadGrid.  The behavior is consistent so should be able to be determined why.

    Each row on the RadGrid points to a project which has as one of its not visible fields a url to its project folder on AWS.

    The code to change the folder location is contained in a method that is called from RadGrid2_ItemCommand.

    The FileExplorer shows the contents of the changed folder all the time but with one exception.  If the currently selected Project is the first on the list, then the FileExplorer does not show the contents of the new folder whenever a different Project is selected.  Reselecting the same Project will get FileExplorer to show the contents of the new folder.  If the currently selected Project is anything other than the first Project, the FileExplorer will show the contents of the new folder.

    I have logged the value of FileExplorer1.CurrentFolder before the change and then again after the change.  When selecting away from the first Project, this value does not change.  All other times the value changes.  What may be relevant is that on the Page_Load, I also log the value of FileExplorer1.CurrentFolder, if it is a Postback, and saw that the value has since been changed but the visual aspect of the FileExplorer still shows the first Project's folder.

    On Page_Load (not a Postback), the Forward, NewFolder and Open are all removed from the ToolBar,ContextMenus[0] and GridContextMenu.

    How do I get the FileExplorer to show the contents of the new folder when selecting away from the first Project?

     

    <telerik:RadFileExplorer RenderMode="Lightweight" runat="server" ID="FileExplorer1"
       Width="595px" Height="350px" AllowPaging="true" PageSize="10"
       VisibleControls="ContextMenus,Grid,Toolbar">
       <Configuration EnableAsyncUpload="true"></Configuration>
    </telerik:RadFileExplorer>

     

    protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "RowClick")
        {
           GridDataItem item = (GridDataItem)e.Item;
          switch (e.Item.OwnerTableView.Name)
          {
             case "Missions":
                // do something else
                break;
             case "Projects":
                string tempLocation = item["colFullDirectory"].Text;
                string newDrive = String.Format("~/aws/{0}", tempLocation.Substring(9));
                SetFileExplorerPaths(newDrive);

    ...

     

    private void SetFileExplorerPaths(string folderPath)
    {
       string[] paths = new string[]
       {
          folderPath
       };
       FileExplorer1.InitialPath = Page.ResolveUrl(folderPath);
       FileExplorer1.Configuration.UploadPaths = paths;
       FileExplorer1.Configuration.ViewPaths = paths;
       FileExplorer1.Configuration.DeletePaths = paths;
    }

     

     

  2. Paul
    Paul avatar
    5 posts
    Member since:
    Oct 2016

    Posted 21 Oct in reply to Paul Link to this post

    An update:

    Forcing a Postback on the page gets the FileExplorer to update but it takes ages and visually not appealing.

    if (FileExplorer1.CurrentFolder != newDrive)
    {
       Response.Write("<body OnLoad=\"javascript:__doPostBack('ForcePostBack','');\">");
    }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vessy
    Admin
    Vessy avatar
    1382 posts

    Posted 24 Oct Link to this post

    Hi Paul,

    Can you share the version of the controls used in your application? I am asking you that as prior to version 2015.2.623 it was not possible to update the paths of RadFileExplorer later than the page_Load (like the Grid's ItemCommand one is). If you are using a previous version of the controls, the easiest way will be to upgrade to a later than Q2 2015 version so you will be able to update FileExplorer after Page_Load event.

    If you decide not to upgrade, though, I would suggest you to pass the information of the selected row using a hidden field and use AJAX request to update the RadFileExplorer.

    Regards,
    Vessy
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
  5. Paul
    Paul avatar
    5 posts
    Member since:
    Oct 2016

    Posted 24 Oct in reply to Vessy Link to this post

    Hi Vessy,

    That makes sense that the forced Postback works if Page_Load is the latest time in which to update the RadFileExplorer.

    We are using a version from 2012 (I inherited the project) so I have switched my attention to the JavaScript RowClick functionality.  Is set_currentDirectory or loadFolder the best method to use?  I am currently getting "Invalid characters in folder name" if I switch to any other folder than the one set in RadGrid2_NeedDataSource.  There are no invalid characters in the folder name.

    var newPathResolved = ResolveUrl(newPath);
    var oExplorer = $find('<%=FileExplorer1.ClientID%>');
    oExplorer.set_currentDirectory(newPathResolved, false);
    oExplorer.refresh();

    Thanks

    Paul

  6. Paul
    Paul avatar
    5 posts
    Member since:
    Oct 2016

    Posted 24 Oct in reply to Vessy Link to this post

    Vessy,

    In tandem, I am also trying out the 2016 trial version to see how it performs.  Switching back to the server side code, I am getting the error, "You are trying to navigate to a non-existing folder or you do not have proper permissions to view this folder.  Please, contact the administrator."  If I click on the same row again, the FileExplorer is updated and the error message is not raised so I question the accuracy of the error message.  The UX is still not good as the user has to click on the row twice for the FileExplorer to show the update.  Do I need to make any modifications to my original code above?

    Incidentally, I noticed some strange behavior with an "invisible" field.  Setting the visible property of a field to "false", the Text property of the item contains "&nbsp;".  If I make the field visible, the data bound contents are available.  I do not desire this field to be visible.  Any insights on this?

    I am trying to make a strong case for upgrading to the latest version but the results I am seeing are not helping.

    Thanks

    Paul

  7. Vessy
    Admin
    Vessy avatar
    1382 posts

    Posted 27 Oct Link to this post

    Hi Paul,

    The error received after upgrading to the latest release is thrown when the value set the InitialPath property of FileExplorer is not correct. Please, note, that the value should be exactly the same as the path displayed in the FileExplorer's AddressBar:


    Furthermore, if the value you are setting to the RadFileExplorer is pointing to the same folder which is set as its ViewPaths (the root folder) you can freely remove the InitialPath setting, s RadFileExplorer will load the same folder by default.

    As for your select folder implementation - I will need to examine the code causing the "Invalid characters in folder name" in order to assist you further with this. I assume that the grid is somehow encoding the paths you assigning to its rows, but still this is only a guessing.

    Regarding the difference between the set_currentDirectory() and loadFolder() methods - the former will select the given directory, while the latter will directly load the folder (selecting it and refreshing the grid with its content).

    I hope this information will be helpful for you.

    Regards,
    Vessy
    Telerik by Progress
    Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017