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

Renaming File, disallow extensions, cancel move?

11 Answers 178 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 09 Jan 2012, 10:52 AM
Hi,
I have a FileExplorer which allows certain types of Image files.  What we would like to achieve is to disallow the user renaming the file extension. We are happy to let them rename the file just not the extension.  I have created the below code based on information I found from your help documents.  Unfortunately, although this does work and does cancel the action, it gets rid of the file rename dialogue box. Which means that after a rename, we can tell the user they cannot change the extension but then the window is closed and they have to click rename again.   So, my questions are:

A. Is there a way to tell the FileExplorer to disallow extension renaming? (simply don't give them the extension in the textbox maybe)
B. Is there another event which fire before the box closes to I can check the extensions and cancel the rename before the box closes?
C. Is there a way to keep the rename dialogue open from the below code?

Thanks,
Michael 

Protected Sub docExplorer_ItemCommand(ByVal sender As Object, ByVal e As RadFileExplorerEventArgs) Handles docExplorer.ItemCommand
    Select Case e.Command
        Case "MoveFile"
            Dim oldExt As String = System.IO.Path.GetExtension(e.Path)
            Dim newExt As String = System.IO.Path.GetExtension(e.NewPath)
            If Not oldExt = newExt Then
                e.Cancel = True
            End If
            Exit Select
 
    End Select

11 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 12 Jan 2012, 08:08 PM
Hi Michael,

In short, no, it is not possible to configure RadFileExplorer to "hide" the extensions of the files in the Rename dialog, nor its possible to keep the dialog open. The closest solution to this case that I offer, is to handle the ClientMove client-side event and cancel it if the file extension is changed, e.g.:
function explorerMove(explorer, args)
{
    //check if the event is fired by Rename command
    if (args.get_newPath().search("/") < 0) {
        if (!args.get_item().isDirectory()) { //check if the renamed item is file or folder
 
            var orgExt = args.get_path().substring(args.get_path().lastIndexOf("."));
            var newExt = args.get_newPath().substring(args.get_newPath().lastIndexOf("."));
 
            if (orgExt != newExt) {
                alert("Changing the file extension is not allowed");
                args.set_cancel(true); //cancel further execution of the command
            }
        }
    }
}

Handling the client-side event will prevent the unnecessary postback to the server, however, the user will have to call the Rename dialog again.

Regards,
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
Michael
Top achievements
Rank 1
answered on 16 Jan 2012, 12:22 PM
Hi Dobromir  
,
Thanks for your response. We have decided to go about it slightly differently in that now if the user changes the file extension we add the file extension back on. So if File.txt get renamed to File.doc we would force the extension on so the file would become File.doc.txt.  Not ideal but does the job.

If it could be submitted as a feature request that would be brilliant. I can imagine there are many people not wanting to allow there users to rename files and although the current solution works it isn't ideal from a user 
point of view.

Many Thanks,
Michael
0
Dobromir
Telerik team
answered on 16 Jan 2012, 01:39 PM
Hi Michael,

I have added your Feature Request to our PITS System, where you can vote for it and follow its status.
You can find the PITS Item following this link.

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
Rohan
Top achievements
Rank 1
answered on 27 Jun 2012, 02:46 PM
Hi all,

How to differentiate whether file is rename or move to different folder of file Explorer at client side.

How to uses  OnClientMove event for this operation.

0
Dobromir
Telerik team
answered on 28 Jun 2012, 10:52 AM
Hi Rohan,

To distinct the action raised OnClientMove event, Rename or Move, you can use the NewPath property of the event arguments - when renaming an item the NewPath contains only the name and not full path. So you can check for pathseparator element in the value returned by the get_newPath() method, e.g.:
function OnClientMove(oExplorer, args)
{ // When renaming, the get_newPath() returns only the name of the item.
    // The name does not contain any slashes
    var isRename = args.get_newPath().search("/") < 0;
    // When moving, the get_newPath() returns the destination directory's path.
    // The name does contain least one slash
    var isMove = args.get_newPath().search("/") >= 0;
    alert("isRename : " + isRename + "\n isMove : " + isMove);
    alert(args.get_newPath());
}

You can find detailed information regarding RadFileExplorer's Client-Side events in this help article.

Regards,
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
Rohan
Top achievements
Rank 1
answered on 03 Jul 2012, 02:33 PM

Hi Dobromir ,
Thank you for your replay,

 For Telelrik Rad Grid - Can’t see the drop and drag functionality.  Ex. When dropping a column for grouping  - cannot see the column while dragging.  On the Telerik site – it shows the column header while dragging.

Code-

  <telerik:RadGrid ID="grdLog" runat="server" AutoGenerateColumns="False" OnItemCommand="grdLog_ItemCommand" OnNeedDataSource="grdLog_NeedDataSource" ShowGroupPanel="True" AllowPaging="True"  AllowSorting="true" Width="100%">
                
                 <ExportSettings HideStructureColumns="true" ExportOnlyData="true" OpenInNewWindow="true" IgnorePaging="true" />
                                    <MasterTableView CommandItemDisplay="Top"  AllowFilteringByColumn="true">
                                  
                                    <PagerStyle AlwaysVisible="true"/>
                                    <CommandItemTemplate>
                                    <table>
                                    <tr>
                                    <td>
                                     <asp:Button ID="btnRefresh" runat="server" CommandName="Rebind" CssClass="rgRefresh" ToolTip="Refresh content." />
                                    </td>
                                    <td>
                                    <asp:Button ID="ExportToExcelButton" runat="server" CommandName="ExportToExcel" CssClass="rgExpXLS" ToolTip="Export to Excel." />
                                    </td>
                                    <td>
                                    <asp:Button ID="ExportToWordButton" runat="server" CommandName="ExportToWord" CssClass="rgExpDOC" ToolTip="Export to Work." />
                                    </td>
                                    <td>
                                    <asp:Button ID="ExportToPdfButton" runat="server" CommandName="ExportToPdf" CssClass="rgExpPDF" ToolTip="Export to PDF." />
                                    </td>
                                    <td>
                                    <asp:Button ID="ExportToCsvButton" runat="server" CommandName="ExportToCsv" CssClass="rgExpCSV" ToolTip="Export To CSV." />
                                    </td>
                                    <td>
                                    <asp:ImageButton ID="imgHideUnhide" runat="server" CommandName="HideUnhide" ImageUrl="~//images/SearchCrawler_16px.gif"  OnClientClick="hideFilterItem()" ToolTip="Hide Or Unhide Filter." />
                                    </td>
                                    </tr>
                                    </table>
                                    </CommandItemTemplate>
                                    <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true"
                                        ShowExportToCsvButton="true"  ShowAddNewRecordButton="false" ShowRefreshButton="false"/>
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="Username" HeaderText="User Name" SortExpression="Username" ></telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Name" HeaderText="File/Folder" SortExpression="Name" ></telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="F_Status" HeaderText="Status" SortExpression="F_Status"  ></telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="LogDate" HeaderText="Log Date" SortExpression="LogDate"  ></telerik:GridBoundColumn>
                                        </Columns>

                                    </MasterTableView>
                             <ClientSettings  AllowDragToGroup="True" >
                <Selecting AllowRowSelect="True"></Selecting>
            </ClientSettings>
            <GroupingSettings ShowUnGroupButton="true" />
                                </telerik:RadGrid>
                                </telerik:RadAjaxPanel>

Once again thanks for replay and your guidance.

0
Dobromir
Telerik team
answered on 05 Jul 2012, 03:35 PM
Hi Rohan,

Could you please post you RadGrid's questions in the corresponding Forum section?

Regards,
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
Rohan
Top achievements
Rank 1
answered on 10 Aug 2012, 10:17 AM
Hi Dobromir

I want to get root node's value and Text on onClientMove event, how can i get the values ...
0
Dobromir
Telerik team
answered on 15 Aug 2012, 08:34 AM
Hi Rohan,

You can access the root node of the tree using the following approach:
function explorerMoveHandler(explorer, args)
{
    var rootNode = explorer.get_tree().get_nodes().getNode(0);//get reference to the tree's root node
    var rootValue = rootNode.get_value();
    var rootText = rootNode.get_text();
}


Kind regards,
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
Rohan
Top achievements
Rank 1
answered on 23 Aug 2012, 11:32 AM
Hi all,
How to persistence the selected row of file explorer during the sorting and paging of telelrik file explorer grid.
I detected  TELERIKs new version have  already build in functionality of persistence the selected row during the sorting and paging. i am using DOTNETNUKE 6.1.5 and telelrik version is -2012.1.411.35,
is there any version problem ? or how can i do this ...
0
Vessy
Telerik team
answered on 27 Aug 2012, 10:31 AM
Hi Rohan,

I have already answered your question in the other forum thread.

Regards,
Veselina
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.
Tags
FileExplorer
Asked by
Michael
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Michael
Top achievements
Rank 1
Rohan
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or