|
Article relates to
|
RadFileExplorer
|
|
Created by
|
Fiko, Telerik
|
|
Last modified
|
May 30, 2011
|
|
Last modified by
|
Marin
|
HOW-TO
Add custom field in the
GridContextMenu and implement the server functionality when that field is clicked. The problem is passing the path of the selected item to the server. The
RadFileExplorer control does not have server property that holds the currently selected file's path. The
CurrentFolder property is similar, but it holds the path to the currently selected directory.
We need to use some client-side and server-side scripts in order to achieve the desired result.
The first approach :
- Create a RadMenuItem and add it to the GridContextMenu's item collection :
C# :
VB.NET :
- Attach a handler to the GridContextMenu''s OnClientItemClicked event as follows :
C# :
VB.NET :
- Add an RadAjaxPanel to the page. Attach a server handler to the OnAjaxRequest event. Please note that you can use different approach in this step (for example __doPostBack() function instead of the ajax request).
- Implement the OnGridContextItemClicked function as follows :
Inside of this function we found the RadFileExplorer's client-side object and use its API in order to get the selected item. Then we trigger an AJAX request to the server and pass the path to the selected file as a parameter of the ajaxRequest() function.
- The AJAX request is handled on the server as follows :
C# :
VB.NET :
The second approach :
In this case, we use an asp:HiddenField and store the selected item's path in its value property :
- You need to implement the steps from 1 to 3 of the first described approach
- Then implement the OnGridContextItemClicked function as follow :
- On the server you can get the value of the hidden field as follow :
C# :
VB.NET :
Please
Sign In
to rate this article.