SERVER-SIDE CODE ON CUSTOM BUTTON IN RADFILEEXPLORER

2 posts, 0 answers
  1. Ajay
    Ajay avatar
    66 posts
    Member since:
    May 2009

    Posted 07 Oct 2009 Link to this post

    Hi Telerik !

    Iam using the RAD FILE EXPLORER control in my project. I have added the CUSTOM BUTTON on to the RADTOOLBAR & named "ARCHIVE " . As result of which it gets appeared on to both the

    a. TREE VIEW
    b. GRID CONTEXT VIEW

    Now what I want to do is to get the path of the folder or file of the selected ITEM(folder/file) in javascript , so that I can ARCHIVE the selected folder/file.

    Presently, iam getting the FILE name using javascript function but Im not getting the FULL PATH where that particular file is located.

    Please help me to solve the problem.

    Iam using the below mentioned code in my file :-

    <asp:Content ID="Content1" ContentPlaceHolderID="MasterContentPlaceHolder" runat="Server">  
     
        <script language="javascript" type="text/javascript">  
     
            function OnClientFileOpen(oExplorer, args) {  
                var item = args.get_item();  
                var fileExtension = item.get_extension();  
                // File is a image document, do not open a new window  
                args.set_cancel(true);  
     
                // Tell browser to open file directly  
                var requestImage = "FileSystemHandler.ashx?path=" + item.get_url();  
                document.location = requestImage;  
                //}  
            }  
     
     
            function toolbarClicked(toolbar, args) {  
                debugger  
                var buttonValue = args.get_item().get_value();  
                if (buttonValue == "Archive")  
                    DoPostBack();  
            }  
     
            function gridContextMenuClicked(toolbar, args) {  
                debugger  
                var buttonValue = args.get_item().get_value();  
                //var filename = args._targetElement.childNodes[0].nodeValue;  
                //var test = filename;  
                //var buttontext = args.get_node().get_contextMenu().get_selectedValue();  
                if (buttonValue == "Archive") {  
                    DoPostBack();  
                }  
     
                //var filelocation = "Z:\testdmsdocs\SharedDocuments" + filename.get_url();  
                //document.location = filelocation;  
                             
                      
                  
            }  
     
            function treeContextMenuClicked(toolbar, args) {  
                debugger  
                var buttonValue = args.get_menuItem().get_value();  
                if (buttonValue == "custom_Menu")  
                    DoPostBack();  
            }  
     
            function DoPostBack() {  
                __doPostBack('Archive', 'Archive');  
            }  
     
            function attachHandlers(explorer, args) {  
                 
                var toolbar = explorer.get_toolbar();  
                toolbar.add_buttonClicked(toolbarClicked);  
                //support for tree context menu  
                var tree = explorer.get_tree();  
                tree.add_contextMenuItemClicked(treeContextMenuClicked);  
                //support for grid context menu  
                var gridContextMenu = explorer.get_gridContextMenu();  
                gridContextMenu.add_itemClicked(gridContextMenuClicked);  
            }  
     
            function OnClientDelete(oExplorer, args) {  
     
                var isRoot = isRootDir(oExplorer.get_tree(), args.get_path());  
                // Check whether the moved item is a directorty and whether it is the root directory;  
                if (args.get_item().isDirectory() && isRoot) {  
                    alert("You cannot delete the root directory");  
                    args.set_cancel(true);  
                }  
     
            }  
     
            function OnClientMove(oExplorer, args) {  
     
                var isRoot = isRootDir(oExplorer.get_tree(), args.get_path());  
                // Check whether the moved item is a directorty and whether it is the root directory;  
                if (args.get_item().isDirectory() && isRoot) {  
                    // Check whether this is a renaming ;  
                    if (isRenaming(args.get_newPath())) {// The renaming operation ;  
                        alert("You cannot rename the root directory");  
                        args.set_cancel(true);  
                    }  
                }  
            }  
     
            function isRootDir(oTree, path) {  
                var dirForDelete = oTree.findNodeByValue(path);  
     
                if (dirForDelete != null) {  
                    return dirForDelete.get_level() == 0;  
                }  
                // Will occurs only when the "path" parameter is not a valid folder path.  
                else return false  
            }  
     
            function isRenaming(destPath) {  
                if (destPath.search("/\//") == -1) {  
                    return true;  
                }  
                else {  
                    return false;  
                }  
            }  
           
        </script> 
     
        <style type="text/css">  
            .test_button span span span span  
            {  
                background-image: none !important;  
                padding-left: 2px !important;  
                border: solid 1px grey;  
            }  
        </style> 
        <table width="100%">  
            <tr> 
                <td> 
                    <%-- <div id="eventConsole" style="height: 470px; width: 300px; overflow: auto; display:none;">  
                    </div>--%> 
                    <telerik:RadFileExplorer runat="server" ID="DocumentsRadFileExplorer" Width="734px" 
                        Height="400px" VisibleControls="All" EnableCreateNewFolder="true" EnableCopy="true" 
                        EnableOpenFile="true" OnClientMove="OnClientMove" OnClientDelete="OnClientDelete" 
                        OnClientLoad="attachHandlers"    
                        OnClientFileOpen="OnClientFileOpen"   
                        ongridpopulated="DocumentsRadFileExplorer_GridPopulated">  
                        <Configuration SearchPatterns="*.*" MaxUploadFileSize="10485760"></Configuration> 
                    </telerik:RadFileExplorer> 
                </td> 
            </tr> 
        </table> 
    </asp:Content> 
     
    While the  method that Iam using in my FILESYSTEM.CS file is shown below as :-

    public static string ArchiveFolder(string path)  
        {  
            string NewFile_Name = "";  
            string File_Path = "";  
            Glb_Entities.ExecuteSP(new object[] {"Usp_Dms_ArchiveFile"          
                ,"File_Name", path.Substring( path.LastIndexOf("/")+1)  
                ,"NewFile_Name", NewFile_Name  
                ,"File_Path", File_Path  
                ,"File_ArchivedBy", HttpContext.Current.Session["UserID"].ToString()  
                });  
            return string.Empty;  
     
        } 
    It would be my pleasure if you please help me try to solve my problem.

    Thanks

    Ajay
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 12 Oct 2009 Link to this post

    Hello Ajay,

    I believe that these KB article will be of help:


    All the best,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top