RadGridView - filtering on key down and getting CurrentColumn

3 posts, 1 answers
  1. tomsky
    tomsky avatar
    10 posts
    Member since:
    Jan 2013

    Posted 03 Apr 2013 Link to this post

    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. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 04 Apr 2013 Link to this post

    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.

  3. DevCraft banner
  4. tomsky
    tomsky avatar
    10 posts
    Member since:
    Jan 2013

    Posted 04 Apr 2013 Link to this post

    Hi Rossan,

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

    Kind regards
Back to Top