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

[Solved] Update custom filter on textchange

7 Answers 159 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Berthold
Top achievements
Rank 1
Berthold asked on 29 Jul 2010, 05:22 PM
Hi, 

I want to use ease the usage of the textfilter in the TextColumnHeader ( custom filter row)
Therfore I use
this.FilterDescriptor.Operator = FilterOperator.StartsWith; // defaultfilter
        this.IsFilterActive = true;
 in the  OnTextChanged()  event of the textbox. 

It runs nearly perfect. Unfortunately the grid will be updated after I leave the textfield, not directly when I input the text.
I seems an event is missing. 

In BooleanColumnHeader (OnCheckBoxStateChanged) it runs perfect.

Any ideas?
Thanks
Berthold

7 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 29 Jul 2010, 06:03 PM
Hello Berthold,

 If you wish to make the RadGridView update while you are typing, you only need to set the UpdateSourceTrigger of the Binding in the ColumnHeader's TextBox to PropertyChanged like so:

<TextBox Grid.Column="0" Text="{Binding FilterDescriptor.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch"/>

All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Berthold
Top achievements
Rank 1
answered on 29 Jul 2010, 08:23 PM
Hi, 

sounds easy, but after I've done this I got an "System.Windows.Markup.XamlParseException occurred" error. 
It seems something is missing in the code behind, isn't it?

Thanks
Berthold 
0
Yavor Georgiev
Telerik team
answered on 30 Jul 2010, 09:20 AM
Hi Berthold,

 Here is the source code for TextColumnHeader.xaml, with the small modification I told you about. You needn't modify anything else in the code to get this working. Just remember: you need to choose a filter first, only then will the GridView start searching when you type.

<local:ColumnFilterCell x:Class="Telerik.Windows.Controls.GridView.Filter.TextColumnHeader"
    xmlns:telerikDrag="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    xmlns:local="clr-namespace:Telerik.Windows.Controls.GridView.Filter">
    <Border>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBox Grid.Column="0" Text="{Binding FilterDescriptor.Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch"/>
            <ContentControl Grid.Column="1" Content="{Binding FilterVisibility}">
                <telerik:RadContextMenu.ContextMenu>
                    <telerik:RadContextMenu ItemsSource="{Binding FilterOperators}" EventName="MouseLeftButtonUp">
                    </telerik:RadContextMenu>
                </telerik:RadContextMenu.ContextMenu>
            </ContentControl>
        </Grid>
    </Border>
</local:ColumnFilterCell>

Greetings,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Berthold
Top achievements
Rank 1
answered on 30 Jul 2010, 10:22 AM
Hi Yavor,

thanks for your code, but the exception still occurred.

Even when I use your default project  (ExampleCS_SL - downloaded a few days ago, Subproject: Gridview.Silverlight, Folder: CustomFilterRow)  and add "UpdateSourceTrigger=PropertyChanged" to the Text-Binding the exception occurred when TextColumnHeader tries to initialize components

 

 

public TextColumnHeader()

 

{

    InitializeComponent(); <-- Exception

}


At last I copied your whole xaml-code into this class - same behaviour.

Regards
Berthold
 
0
Yavor Georgiev
Telerik team
answered on 30 Jul 2010, 10:40 AM
Hello Berthold,

 I apologize for misleading you, I was under the impression you were using WPF rather than Silverlight. In Silverlight, you need to handle the TextChanged event of the TextBox like so:

private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
    var box = sender as System.Windows.Controls.TextBox;
 
    var expr = box.GetBindingExpression(System.Windows.Controls.TextBox.TextProperty);
    expr.UpdateSource();
}

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Berthold
Top achievements
Rank 1
answered on 30 Jul 2010, 12:19 PM
Hi Yavor,

thanks a lot - that was it.

Berthold
0
Muruganas
Top achievements
Rank 1
answered on 23 Dec 2010, 02:48 PM
HI 

  I am using the custom Filter Row. I want to set  Default Filter for the each column . 
i am using Textchanged event also.it is working fine after select the Filter from Contextmenu.
so how to Fix the Default filter  for User.

i was set the default filter while creating ColumnCellFactory but it is not working, how to implement that one.
Regards
murugan
Tags
GridView
Asked by
Berthold
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Berthold
Top achievements
Rank 1
Muruganas
Top achievements
Rank 1
Share this question
or