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

Default filters not working

5 Answers 308 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 04 Aug 2013, 10:51 AM
I have a simple gird setup with a RadEntityFrameworkDataSource, RadDataPager, and RadGridView linked it works great with one exception, filters I set programmatically don't seem to trigger the underlying datasource to update.  

Telerik.Windows.Controls.GridViewColumn timeColumn = this.RadGridView1.Columns["subject_timestamp"];
Telerik.Windows.Controls.GridView.IColumnFilterDescriptor timeFilter = timeColumn.ColumnFilterDescriptor;
timeFilter.SuspendNotifications();
timeFilter.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsGreaterThan;
timeFilter.FieldFilter.Filter1.Value = DateTime.Now.AddYears(-1).ToShortDateString();
timeFilter.ResumeNotifications();


It puts the right info into the filters.  If I run this in the constructor of the window after InitializeComponent(), it filters per page of the datagrid.  If I run it attached to a button after load it simply inserts the parameters into the filter and doesn't evaluate.  If I hit clear filter and insert it by hand it works perfectly.  I am just not sure what to do cause it evaluate.

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 05 Aug 2013, 07:24 AM
Hi,

I have tried to reproduce this behavior in a sample project, but it works as expected. Can you please check my sample project out. Is uses AdventureWorks sample DB. Run the project and hit the "Filter" button. The grid is filtered.

Regards,
Rossen Hristov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jeff
Top achievements
Rank 1
answered on 05 Aug 2013, 08:48 AM
I tried to run to test, but I am forced to use 2008R2, the adventure works version for that doesn't have the right tables to play with.
After playing with it, I have found

Telerik.Windows.Controls.GridViewColumn timeColumn = this.RadGridView1.Columns["subject_fname"];
Telerik.Windows.Controls.GridView.IColumnFilterDescriptor timeFilter = timeColumn.ColumnFilterDescriptor;
timeFilter.SuspendNotifications();
timeFilter.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.StartsWith;
timeFilter.FieldFilter.Filter1.Value = "N";
timeFilter.ResumeNotifications();


This works as expected, so it has something to do with filtering on a date column.  Both columns have the correct names no errors.  This is the entire xaml I am using.  Nothing more than this and the above code in the constructor is left.  Not really sure where I could be wrong there is almost no code left, but the original code post still does not work, yet this does.

<DockPanel>
    <telerik:RadEntityFrameworkDataSource Name="AIMEntityFrameworkDataSource" QueryName="Subjects">
        <telerik:RadEntityFrameworkDataSource.ObjectContext>
            <entites:AIMEntities1/>
        </telerik:RadEntityFrameworkDataSource.ObjectContext>
    </telerik:RadEntityFrameworkDataSource>
             
             
            <telerik:RadGridView x:Name="RadGridView1" Grid.Row="1" Grid.Column="1"
                     ItemsSource="{Binding DataView, ElementName=AIMEntityFrameworkDataSource}"
                     Margin="0" GroupRenderMode="Flat"
                     SelectedItem="{Binding SelectedIndex}"
                     RowIndicatorVisibility="Collapsed"
                     IsReadOnly="True"
                     ShowColumnSortIndexes="True"
                     AutoGenerateColumns="False"
                     CanUserFreezeColumns="True"
                     CanUserResizeColumns="True"
                     ValidatesOnDataErrors="None"
                     PreviewMouseDoubleClick="RadGridView1_PreviewMouseDoubleClick">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <cmd:EventToCommand Command="{Binding DoubleClickCommand,Mode=OneWay}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="Subject ID"
                                    DataMemberBinding="{Binding subject_id}"/>
                    <telerik:GridViewDataColumn Header="Last"
                                    DataMemberBinding="{Binding subject_lname}" />
                    <telerik:GridViewDataColumn Header="First"
                                    DataMemberBinding="{Binding subject_fname}" />
                    <telerik:GridViewDataColumn Header="SSN"
                                    DataMemberBinding="{Binding subject_ssn}" />
                    <telerik:GridViewDataColumn Header="TimeStamp"
                                    DataMemberBinding="{Binding subject_timestamp}" />
                    <telerik:GridViewDataColumn Header="Investigator"
                                    DataMemberBinding="{Binding Investigator.inv_full_name}" />
                    <telerik:GridViewDataColumn Header="Company"
                                    DataMemberBinding="{Binding Company.company_name}"
                                    Width="*" />
                </telerik:RadGridView.Columns>
                <!--
                <telerik:RadGridView.SortDescriptors>
                    <telerik:ColumnSortDescriptor Column="{Binding Columns[\subject_id\], ElementName=RadGridView1}" SortDirection="Descending"/>
                </telerik:RadGridView.SortDescriptors>
                -->
 
            </telerik:RadGridView>
            <telerik:RadDataPager x:Name="radDataPager" Grid.Row="2" Grid.Column="1"
                  Source="{Binding Items, ElementName=RadGridView1}"
                  PageSize="50"/>
</DockPanel>

0
Rossen Hristov
Telerik team
answered on 05 Aug 2013, 09:01 AM
Hello,

What is the data type of your column that contains your dates? Is it DateTime or string?

Regards,
Rossen Hristov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jeff
Top achievements
Rank 1
answered on 05 Aug 2013, 09:08 AM
It is a datetime.
0
Rossen Hristov
Telerik team
answered on 05 Aug 2013, 09:39 AM
Hello,

If I can't debug something, I don't know how can I help you. Please, prepare a runnable sample project, open a support ticket and attach it there. I will debug it right away to see what is going on. Thanks in advance.

Regards,
Rossen Hristov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or