Skip to content

Commit e14acf6

Browse files
JMJM
authored andcommitted
Modified ODataDataSource to add basic support for filtering. Modified the sample app to add options which apply to filtering.
1 parent dacd0a2 commit e14acf6

3 files changed

Lines changed: 129 additions & 42 deletions

File tree

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/MainWindow.xaml

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@
1111
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
1212
xmlns:sys="clr-namespace:System;assembly=mscorlib"
1313
mc:Ignorable="d"
14-
Title="MainWindow" Height="700" Width="1000">
14+
Title="MainWindow" Height="700" Width="1100">
1515
<Window.Resources>
1616
<local:ColorToBrushConverter x:Key="colorToBrushConverter"/>
1717
</Window.Resources>
1818

1919
<Grid>
2020
<Grid.ColumnDefinitions>
21-
<ColumnDefinition Width="4*"/>
21+
<ColumnDefinition Width="5*"/>
2222
<ColumnDefinition Width="Auto"/>
2323
<ColumnDefinition Width="9*"/>
2424
</Grid.ColumnDefinitions>
2525

2626
<StackPanel Grid.Column="0" Margin="6">
2727
<StackPanel>
2828
<StackPanel.Resources>
29-
<Style x:Key="HeaderText" TargetType="TextBlock">
29+
<Style x:Key="HeaderText1" TargetType="TextBlock">
30+
<Setter Property="FontWeight" Value="Bold"/>
31+
<Setter Property="Foreground" Value="#FF0052A6"/>
32+
<Setter Property="Margin" Value="0,3"/>
33+
<Setter Property="FontSize" Value="18"/>
34+
</Style>
35+
36+
<Style x:Key="HeaderText2" TargetType="TextBlock">
3037
<Setter Property="FontWeight" Value="Bold"/>
3138
<Setter Property="Foreground" Value="#FF0072C6"/>
3239
<Setter Property="Margin" Value="0,3"/>
@@ -71,8 +78,8 @@
7178
</Style>
7279
</StackPanel.Resources>
7380

74-
<!-- OData Sources -->
75-
<TextBlock Text="ODATA SOURCES" Style="{StaticResource HeaderText}"/>
81+
<!-- ODATA SERVICES-->
82+
<TextBlock Text="ODATA SERVICES" Style="{StaticResource HeaderText1}"/>
7683
<ComboBox x:Name="cboOdataSources" SelectionChanged="cboOdataSources_SelectionChanged" Style="{StaticResource ComboBoxText}">
7784
<local:ODataSourceListItem BaseUri="http://services.odata.org/V4/Northwind/Northwind.svc" EntitySet="Orders" Description="Northwind Orders"/>
7885
<local:ODataSourceListItem BaseUri="http://services.odata.org/AdventureWorksV3/AdventureWorks.svc" EntitySet="CompanySales" Description="AdventureWorks Company Sales"/>
@@ -87,9 +94,15 @@
8794
</ComboBox>
8895
<CheckBox x:Name="chkNullOutDatasource" IsChecked="True" Style="{StaticResource CheckBoxText}">Null out datasource before setting new</CheckBox>
8996

90-
<!-- Desired Page Size -->
97+
<!-- Separator -->
98+
<Rectangle Height="1" HorizontalAlignment="Stretch" Fill="Gray" Margin="5,20,5,0"/>
99+
100+
<!-- DATA SOURCE SETTINGS -->
91101
<Rectangle Width="1" Height="20" Fill="Transparent"/>
92-
<TextBlock Text="DATASOURCE DESIRED PAGE SIZE" Style="{StaticResource HeaderText}"/>
102+
<TextBlock Text="DATASOURCE SETTINGS" Style="{StaticResource HeaderText1}"/>
103+
104+
<!-- Desired Page Size -->
105+
<TextBlock Text="DESIRED PAGE SIZE" Style="{StaticResource HeaderText2}"/>
93106
<igEditors:XamNumericEditor x:Name="numDesiredPageSize" Width="100" HorizontalAlignment="Left" Mask="9999" EditModeEnded="numDesiredPageSize_EditModeEnded" SpinButtonDisplayMode="Always" SpinIncrement="10" Style="{StaticResource NumericEditorText}">
94107
<igEditors:XamNumericEditor.ValueConstraint>
95108
<igEditors:ValueConstraint MinInclusive="5" MaxInclusive="1000"/>
@@ -98,7 +111,7 @@
98111

99112
<!-- Maximum number of cached pages -->
100113
<Rectangle Width="1" Height="20" Fill="Transparent"/>
101-
<TextBlock Text="DATASOURCE MAX # CACHED PAGES" Style="{StaticResource HeaderText}"/>
114+
<TextBlock Text="MAX # CACHED PAGES" Style="{StaticResource HeaderText2}"/>
102115
<igEditors:XamNumericEditor x:Name="numMaximumCachedPages" Width="100" HorizontalAlignment="Left" Mask="9999" EditModeEnded="numMaximumCachedPages_EditModeEnded" SpinButtonDisplayMode="Always" SpinIncrement="10" Style="{StaticResource NumericEditorText}">
103116
<igEditors:XamNumericEditor.ValueConstraint>
104117
<igEditors:ValueConstraint MinInclusive="5" MaxInclusive="1000"/>
@@ -108,9 +121,12 @@
108121
<!-- Separator -->
109122
<Rectangle Height="1" HorizontalAlignment="Stretch" Fill="Gray" Margin="5,20,5,0"/>
110123

111-
<!-- Pending Message Settings -->
112124
<Rectangle Width="1" Height="20" Fill="Transparent"/>
113-
<TextBlock Text="DATA PENDING MESSAGE" Style="{StaticResource HeaderText}"/>
125+
<TextBlock Text="DATAPRESENTER SETTINGS" Style="{StaticResource HeaderText1}"/>
126+
127+
<!-- Pending Message Settings -->
128+
<Rectangle Width="1" Height="5" Fill="Transparent"/>
129+
<TextBlock Text="DATA PENDING MESSAGE SETTINGS" Style="{StaticResource HeaderText2}"/>
114130
<Grid>
115131
<Grid.ColumnDefinitions>
116132
<ColumnDefinition Width="3*"/>
@@ -137,27 +153,62 @@
137153
<CheckBox x:Name="chkShowProgressBar" Grid.Row="3" Grid.Column="1" Margin="0,2" IsChecked="False" Style="{StaticResource CheckBoxText}" Checked="chkShowProgressBar_Checked" Unchecked="chkShowProgressBar_Checked"/>
138154
</Grid>
139155

140-
<!-- XamDataPresenter View -->
156+
<!-- Filter Settings -->
141157
<Rectangle Width="1" Height="20" Fill="Transparent"/>
142-
<TextBlock Text="DATAPRESENTER VIEW" Style="{StaticResource HeaderText}"/>
143-
<ComboBox x:Name="cboDataPresenterView" SelectionChanged="cboDataPresenterView_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
144-
<sys:String>GridView</sys:String>
145-
<sys:String>CardView</sys:String>
146-
<sys:String>CarouselView</sys:String>
147-
<sys:String>TreeView</sys:String>
148-
</ComboBox>
158+
<TextBlock Text="FILTER SETTINGS" Style="{StaticResource HeaderText2}"/>
159+
<Grid>
160+
<Grid.ColumnDefinitions>
161+
<ColumnDefinition Width="3*"/>
162+
<ColumnDefinition Width="2*"/>
163+
</Grid.ColumnDefinitions>
164+
165+
<Grid.RowDefinitions>
166+
<RowDefinition />
167+
</Grid.RowDefinitions>
168+
169+
<TextBlock Grid.Row="0" Grid.Column="0" Text="RECORD FILTER LOGICAL OPERATOR" Style="{StaticResource LabelText}"/>
170+
<ComboBox x:Name="cboRecordFilterLogicalOperator" Grid.Row="0" Grid.Column="1" SelectionChanged="cboRecordFilterLogicalOperator_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
171+
<sys:String>And</sys:String>
172+
<sys:String>Or</sys:String>
173+
</ComboBox>
174+
</Grid>
175+
176+
<!-- Appearance Settings -->
177+
<Rectangle Width="1" Height="20" Fill="Transparent"/>
178+
<TextBlock Text="APPEARANCE SETTINGS" Style="{StaticResource HeaderText2}"/>
179+
<Grid>
180+
<Grid.ColumnDefinitions>
181+
<ColumnDefinition Width="3*"/>
182+
<ColumnDefinition Width="2*"/>
183+
</Grid.ColumnDefinitions>
184+
185+
<Grid.RowDefinitions>
186+
<RowDefinition />
187+
</Grid.RowDefinitions>
188+
189+
<TextBlock Grid.Row="0" Grid.Column="0" Text="VIEW" Style="{StaticResource LabelText}"/>
190+
<ComboBox x:Name="cboDataPresenterView" Grid.Row="0" Grid.Column="1" SelectionChanged="cboDataPresenterView_SelectionChanged" Margin="2" Style="{StaticResource ComboBoxText}">
191+
<sys:String>GridView</sys:String>
192+
<sys:String>CardView</sys:String>
193+
<sys:String>CarouselView</sys:String>
194+
<sys:String>TreeView</sys:String>
195+
</ComboBox>
196+
</Grid>
197+
149198
</StackPanel>
150199
</StackPanel>
151200

152201
<GridSplitter Grid.Column="1" Width="7" Margin="2,0" Background="#FFDDDDDD" ResizeBehavior="PreviousAndNext"/>
153202

154203
<igDP:XamDataPresenter x:Name="dataPresenter1" Grid.Column="2" Theme="Office2013" Margin="5,0,0,0">
155204
<igDP:XamDataPresenter.FieldLayoutSettings>
156-
<igDP:FieldLayoutSettings DynamicDataPendingBackgroundBrush="#200080FF" DynamicDataPendingForegroundBrush="DarkGray"/>
205+
<igDP:FieldLayoutSettings DynamicDataPendingBackgroundBrush="#200080FF"
206+
DynamicDataPendingForegroundBrush="DarkGray"
207+
FilterEvaluationMode="UseCollectionView"/>
157208
</igDP:XamDataPresenter.FieldLayoutSettings>
158209

159210
<igDP:XamDataPresenter.FieldSettings>
160-
<igDP:FieldSettings LabelClickAction="SortByMultipleFieldsTriState"/>
211+
<igDP:FieldSettings LabelClickAction="SortByMultipleFieldsTriState" AllowRecordFiltering="True"/>
161212
</igDP:XamDataPresenter.FieldSettings>
162213
</igDP:XamDataPresenter>
163214
</Grid>

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData.SampleApp/MainWindow.xaml.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using DataPresenter.DataSources.OData;
2+
using Infragistics.Windows.Controls;
23
using Infragistics.Windows.DataPresenter;
34
using Infragistics.Windows.Themes;
45
using System;
@@ -37,11 +38,12 @@ public MainWindow()
3738
{
3839
InitializeComponent();
3940

40-
this.numDesiredPageSize.Value = 200;
41-
this.numMaximumCachedPages.Value = 200;
42-
this.cboOdataSources.SelectedIndex = 0;
43-
this.cboDataPresenterView.SelectedIndex = 0;
44-
}
41+
this.numDesiredPageSize.Value = 200;
42+
this.numMaximumCachedPages.Value = 200;
43+
this.cboOdataSources.SelectedIndex = 0;
44+
this.cboDataPresenterView.SelectedIndex = 0;
45+
this.cboRecordFilterLogicalOperator.SelectedIndex = 0;
46+
}
4547
#endregion //Constructor
4648

4749
#region Private Properties
@@ -170,6 +172,23 @@ private void cboOdataSources_SelectionChanged(object sender, SelectionChangedEve
170172
}
171173
#endregion //cboOdataSources_SelectionChanged
172174

175+
private void cboRecordFilterLogicalOperator_SelectionChanged(object sender, SelectionChangedEventArgs e)
176+
{
177+
if (null == this.dataPresenter1)
178+
return;
179+
180+
string logicalOperator = (string)this.cboRecordFilterLogicalOperator.SelectedValue;
181+
switch (logicalOperator)
182+
{
183+
case "And":
184+
this.dataPresenter1.FieldLayoutSettings.RecordFiltersLogicalOperator = LogicalOperator.And;
185+
break;
186+
case "Or":
187+
this.dataPresenter1.FieldLayoutSettings.RecordFiltersLogicalOperator = LogicalOperator.Or;
188+
break;
189+
}
190+
}
191+
173192
#region chkShowProgressBar_Checked
174193
private void chkShowProgressBar_Checked(object sender, RoutedEventArgs e)
175194
{

DataPresenter.DataSources.OData/DataPresenter.DataSources.OData/ODataDataSource.cs

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Infragistics.Windows.DataPresenter.DataSources;
99
using Infragistics.Controls;
1010
using Reference.DataSources.OData;
11+
using Infragistics.Windows.Controls;
1112

1213
namespace DataPresenter.DataSources.OData
1314
{
@@ -16,11 +17,14 @@ namespace DataPresenter.DataSources.OData
1617
/// </summary>
1718
public sealed class ODataDataSource : AsyncPagingDataSourceBase
1819
{
19-
#region Constructor
20-
/// <summary>
21-
/// Constructor
22-
/// </summary>
23-
public ODataDataSource()
20+
#region Member Variables
21+
#endregion //Member Variables
22+
23+
#region Constructor
24+
/// <summary>
25+
/// Constructor
26+
/// </summary>
27+
public ODataDataSource()
2428
{
2529
}
2630
#endregion //Constructor
@@ -36,8 +40,7 @@ protected override bool CanFilter
3640
{
3741
get
3842
{
39-
// TODO: Return the appropriate CanFilter value
40-
return false;
43+
return true;
4144
}
4245
}
4346
#endregion //CanFilter
@@ -81,24 +84,36 @@ protected override Freezable CreateInstanceCore()
8184

8285
#region CreateUnderlyingDataSource
8386
/// <summary>
84-
///
87+
/// Returns a <see cref="VirtualDataSource"/> derived class that will serve as the foundation for this datasource implementation. All
88+
/// threaded data page fetches and backend access will be managed and executed by the instance returned from this method.
8589
/// </summary>
8690
/// <returns></returns>
8791
protected override VirtualDataSource CreateUnderlyingDataSource()
8892
{
8993
return new ODataVirtualDataSource();
9094
}
91-
#endregion //CreateUnderlyingDataSource
95+
#endregion //CreateUnderlyingDataSource
9296

93-
#endregion //Base Class Overrides
97+
#region OnEndDeferRefresh
98+
/// <summary>
99+
/// Called when <see cref="IsRefreshDeferred"/> changes to false and modifications to the data are allowed.
100+
/// </summary>
101+
protected override void OnEndDeferRefresh()
102+
{
103+
}
104+
#endregion //OnEndDeferRefresh
94105

95-
#region //Properties
106+
#endregion //Base Class Overrides
96107

97-
#region BaseUri
108+
#region //Properties
109+
110+
#region Public Properties
111+
112+
#region BaseUri
98113
/// <summary>
99114
/// Returns the BaseUri DependencyProperty.
100115
/// </summary>
101-
public static readonly DependencyProperty BaseUriProperty = DependencyProperty.Register("BaseUri",
116+
public static readonly DependencyProperty BaseUriProperty = DependencyProperty.Register("BaseUri",
102117
typeof(string), typeof(ODataDataSource), new PropertyMetadata(default(string), (sender, e) =>
103118
{
104119
((ODataDataSource)sender).OnBaseUriChanged((string)e.OldValue, (string)e.NewValue);
@@ -138,7 +153,7 @@ private void OnEntitySetChanged(string oldValue, string newValue)
138153
this.UnderlyingVirtualDataSource.ResetCache();
139154
if (this.UnderlyingVirtualDataSource.ActualDataProvider is ODataVirtualDataSourceDataProvider)
140155
{
141-
((ODataVirtualDataSourceDataProvider)this.UnderlyingVirtualDataSource.ActualDataProvider).EntitySet = EntitySet;
156+
((ODataVirtualDataSourceDataProvider)this.UnderlyingVirtualDataSource.ActualDataProvider).EntitySet = EntitySet;
142157
}
143158
}
144159

@@ -178,8 +193,10 @@ public int TimeoutMilliseconds
178193
get { return (int)GetValue(TimeoutMillisecondsProperty); }
179194
set { SetValue(TimeoutMillisecondsProperty, value); }
180195
}
181-
#endregion //TimeoutMilliseconds
196+
#endregion //TimeoutMilliseconds
197+
198+
#endregion //Public Properties
182199

183-
#endregion //Properties
184-
}
200+
#endregion //Properties
201+
}
185202
}

0 commit comments

Comments
 (0)