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

How do I access the current filter from the code behind?

5 Answers 125 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 26 Mar 2012, 05:20 PM
I have a custom provider, and in the case where we are creating a new file, I would like to append the current search pattern if the current pattern looks like a file extension and the current file does not have a file extension.  To do this, I need to get the current search pattern from the RadFileExplorer in the code behind.

5 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 28 Mar 2012, 12:18 PM
Hi John,

I am not quite sure I understand the exact scenario, could you please elaborate on the subject? What exactly do you mean by "case where we are creating a new file"? You have implemented custom functionality to RadFileExplorer for creating new files?

You can get the value of the SearchPatterns in the page's from the RadFileExplorer's configuration using the corresponding property
string[] searchPatterns = RadFileExplorer1.Configuration.SearchPatterns;

Or, you can get the value of the explorer's search patterns inside the content provider using its SearchPatterns property.


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
John
Top achievements
Rank 1
answered on 28 Mar 2012, 03:14 PM
Sorry I was not more clear.

I am having several difficulties with the RadFileExplorer at this point. 

The basic scenario is that the user is allowed to select a file from the real file system of a remote computer.  In most cases this is merely selecting a file for the attention of a service on that server, and that portion works OK.  I have added a text box that the user can type a file path in for file creation and browsing to other URLs.  On a Click event of the OK button, we check to see if there is a path to a file selected somehow, or a path to a directory.  If it is a directory, we would like to open that directory (and if it is from a root not already added to the forest, we would like to add that root to the forest).

There are two problem areas.

1)  There are two cases where the user has to select a non-existent file for the service to put some information in.  In this case, the standard in the Windows file selection dialog is to append the extension of the current search filter to the end of the file if the file does not have an extension specified already.  To do this, I need the currently selected filter, not the list of filters.  i.e. if the available filters are *.txt, *.bat, and *.cmd, I need to know which of these three is the currently selected one.

2)  Apparently, it is not possible to set the Configuration properties except in the function Page_Load, and I cannot figure out how to tell when a RadButton is pressed in the Page_Load event.  It is moderately expensive to call the remote server to see if the item is a directory, so I would like to limit the check to being on the OK button click.  If I wait until the OnClick handler, it is apparently too late.
0
John
Top achievements
Rank 1
answered on 28 Mar 2012, 07:47 PM
I figured out how to detect that a particular RadButton is pressed, so #2 has been resolved.
0
Dobromir
Telerik team
answered on 02 Apr 2012, 11:04 AM
Hi John,

Are you using the RadFileExplorer's built-in FilterTextBox or an external control to apply the additional filtering?

If you are using the built-in FilterTextBox, RadFileExplorer does not expose its value in the code-behind, actually, the value of the filter is not preserved over postback. Nevertheless, to pass its current value on the server you can use the following approach:
  • Use a standard hidden field to store the current value of the FilterTextBox.
  • Handle the RadFileExplorer's ClientFilter client-side event and pass the value of the filter to the hidden field.
  • In the code-behind use the value of the hidden field to get the value of the applied filter.
  • Handle client-side events that cause the filter to be reset and reset the value of the hidden field. Such events are: ClientFolderChange, ClientCopy, ClientDelete, ClientMove, CreateNewFolder.

For your convenience I have attached a sample page demonstrating this approach.


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
John
Top achievements
Rank 1
answered on 02 Apr 2012, 03:00 PM
I thought we were using yours.  However, someone had added the a drop down list I was seeing.  Since it is ours, it should be easy to get to.  Sorry about that.
Tags
FileExplorer
Asked by
John
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
John
Top achievements
Rank 1
Share this question
or