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
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
,
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
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
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.
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
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.
Could you please post you RadGrid's questions in the corresponding Forum section?
Regards,
Dobromir
the Telerik team
I want to get root node's value and Text on onClientMove event, how can i get the values ...
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
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 ...
I have already answered your question in the other forum thread.
Regards,
Veselina
the Telerik team