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

RadGridView - filtering on key down and getting CurrentColumn

2 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
tomsky
Top achievements
Rank 1
tomsky asked on 03 Apr 2013, 04:34 PM
Hi,

We've got a silverlight application with dynamic columns. We want to allow the user to filter after they type in something in the header filter text field and press the enter key. This is done through the keyDown event and works fine:

private void rgv_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
 if (e.PlatformKeyCode == 13)
           {
               string textToFilter = ((TextBox)e.OriginalSource).Text;
               GridViewColumn currentColumn = ((RadGridView) sender).CurrentColumn;  
               currentColumn.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.IsEqualTo;
               currentColumn.ColumnFilterDescriptor.FieldFilter.Filter1.Value = textToFilter;
}


 The only problem we're having is with getting the CurrentColumn. The RadGridView.CurrentColumn property is set to the column whose element has been selected (clicked) so when you don't do that, it doesn't return the column whose filter text box has been edited. 

Can you please tell me if there is a way to know what the current (focused) column is after you type in something in the column header filter text box?

2 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 04 Apr 2013, 05:50 AM
Hello,

You don't need to do that. You only need to pre-select a filter operator so that when the user hits enter the filtering will be applied with this operator. If not operator is selected then the user will have to manually select one before filtering takes effect.

I have attached a sample project that shows how to set the default selected operator. With this code, when your user hits Enter the filtering will be applied immediately. There is some more code in the project that shows you how you can tailor the existing field filter editor to your particular needs -- for example to enable filtering on every letter typed by the user.

I hope this helps.

Kind regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
tomsky
Top achievements
Rank 1
answered on 04 Apr 2013, 07:14 AM
Hi Rossan,

Thanks so much for your help. That works exactly as expected and solved our problem.

Kind regards
Tags
General Discussions
Asked by
tomsky
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
tomsky
Top achievements
Rank 1
Share this question
or