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

Filter Row - how to start filtering after each digit in filter search textbox

3 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
CQT
Top achievements
Rank 1
CQT asked on 03 Jan 2013, 08:06 AM
Hello!

I use Telerik WPF Controls Q2 2012 for my project and I have a radgridview with filter row enabled.

In old telerik gridview for winforms each time I write in the search textbox of the filter row gridview starts filtering rows. In WPF Radgridview filtering doesn't starts until I lost focus from search textbox or I press Enter. I would like to get filter row function as the old winform gridview, can anybody halp me please?

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Jan 2013, 10:20 AM
Hello,

I am afraid that this behavior is by design (for performance reasons) and cannot be changed.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
CQT
Top achievements
Rank 1
answered on 03 Jan 2013, 11:12 AM
Hello, thanks for your reply!

My Opinion is that you should give the option to the end-user to choose which type of behavior to use depending on maximum number of rows in the grid. In my case I don't have thousand of rows but only a few hundreds, so I would have real time filtering on each digit.

I'm rewriting an application in wpf previusly written in win forms and users of this application are used to expect filter starts after digits in the textbox and is not very intuitive for them to press enter button to fire filter action.

There is no possibility of overriding this behavior in code?
0
Rossen Hristov
Telerik team
answered on 03 Jan 2013, 12:36 PM
Hello,

You can supply your very own customly crafted TextBox as the filter editor (you will lose the match case button though). Changing the default editor is described in this article.

You can make the TextBox update its Binding on every text change with an attached behavior (TextBoxBehavior class for example) like this one:

public static readonly DependencyProperty UpdateTextOnTextChangedProperty =
    DependencyProperty.RegisterAttached(
    "UpdateTextOnTextChanged",
    typeof(bool),
    typeof(TextBoxBehavior),
    new PropertyMetadata(false, OnUpdateTextOnTextChanged));
 
private static void OnUpdateTextOnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    TextBox textBox = d as TextBox;
 
    if (textBox != null && e.NewValue is bool)
    {
        if ((bool)e.NewValue)
        {
            textBox.TextChanged += new TextChangedEventHandler(TextBox_TextChanged);
        }
        else
        {
            textBox.TextChanged -= new TextChangedEventHandler(TextBox_TextChanged);
        }
    }
}
 
private static void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    BindingExpression expression = ((TextBox)sender).GetBindingExpression(TextBox.TextProperty);
    if (expression != null)
    {
        expression.UpdateSource();
    }
}

Alternatively, you can modify the default editor, which for string columns is called StringFilterEditor. Inside it there is the default TextBox which you should find and make behave with the behavior above.

I hope this helps.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
CQT
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
CQT
Top achievements
Rank 1
Share this question
or