<
telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Path=Table, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" GridLinesVisibility="Both" IsReadOnly="True"
CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" CanUserReorderColumns="False"
ShowGroupPanel="False" HorizontalAlignment="Left" SelectionMode="Extended" SelectionUnit="Cell"
BorderThickness="0">
<
telerik:RadGridView.FilterDescriptors>
<telerik:FilterDescriptor Member="ParentID" Operator="IsEqualTo" Value="0"/>
</telerik:RadGridView.FilterDescriptors>
<
telerik:RadGridView.ChildTableDefinitions>
<telerik:GridViewTableDefinition>
<telerik:GridViewTableDefinition.Relation>
<telerik:TableRelation IsSelfReference="True">
<telerik:TableRelation.FieldNames>
<telerik:FieldDescriptorNamePair ParentFieldDescriptorName="ServiceID" ChildFieldDescriptorName="ParentID"/>
</telerik:TableRelation.FieldNames>
</telerik:TableRelation>
</telerik:GridViewTableDefinition.Relation>
</telerik:GridViewTableDefinition>
</telerik:RadGridView.ChildTableDefinitions>
</telerik:RadGridView>
In the ViewModel,
private
DataTable _table;
public DataTable Table
{
get { return _table; }
set
{
_table = value;
RaisePropertyChanged(() => this.Table);
}
}
[
ImportingConstructor]
public MatrixViewModel(IEventAggregator eventAggregator)
{
this.TabModel = new TabModel { Title = "Matrix" };
if (eventAggregator != null)
eventAggregator.GetEvent<MatrixReloadEvent>().Subscribe(OnContractCreatedOrLoaded);
}
private void OnContractCreatedOrLoaded(ContractCreatedOrLoadedEventArgs args)
{
DataTable dtOutput = new DataTable();
..buliding the datatable and assigning to the Table property
}
From the other screen I am calling the event "OnContractCreatedOrLoaded" while adding new items. For the first time (add 1 or n number of items) and view the grid screen. It works perfectly (Grid will have only one row - ParentID = 0).
Now add 1 new item ("OnContractCreatedOrLoaded" event will be fired) and see the grid, it binds all the rows in the datatable without filtering or hierarchy (grid is having all the rows instead of showing ParentID = 0)
Any help appreciated.
Thanks,
Ramasamy
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
/>
</
Grid.RowDefinitions
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
MinWidth
=
"500"
/>
</
Grid.ColumnDefinitions
>
<
Grid
Grid.Row
=
"0"
Grid.Column
=
"0"
MinWidth
=
"500"
HorizontalAlignment
=
"Stretch"
>
<
telerik:RadRichTextBox
LayoutMode
=
"Flow"
x:Name
=
"editor"
AllowDrop
=
"True"
Drop
=
"editor_Drop"
ShowComments
=
"False"
MinHeight
=
"50"
MaxHeight
=
"100"
BorderBrush
=
"#FFADADAD"
MinWidth
=
"500"
BorderThickness
=
"1"
IsSelectionMiniToolBarEnabled
=
"False"
IsContextMenuEnabled
=
"True"
IsInHeaderFooterEditMode
=
"False"
>
</
telerik:RadRichTextBox
>
</
Grid
>
</
Grid
>
<
GroupBox
Margin
=
"5"
Padding
=
"5"
MinWidth
=
"614"
Header
=
"Stem and/or Stimulus"
Foreground
=
"#FF000000"
>
<
common:HtmlEditor
Name
=
"htmlStem"
GotFocus
=
"htmlEditor_GotFocus"
MinHeight
=
"100"
Margin
=
"0"
Padding
=
"0"
/>
</
GroupBox
>
<
UserControl
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
>
<
UserControl.Resources
>
<
Style
x:Key
=
"CustomBubbleStyle"
TargetType
=
"{x:Type telerik:Bubble}"
>
<
Setter
Property
=
"Diameter"
Value
=
"80"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:Bubble}"
>
<
Canvas
x:Name
=
"PART_MainContainer"
RenderTransformOrigin
=
"{TemplateBinding RelativeCenterPoint}"
>
<
Canvas.RenderTransform
>
<
ScaleTransform
ScaleY
=
"0"
ScaleX
=
"0"
/>
</
Canvas.RenderTransform
>
<
Path
x:Name
=
"PART_BubbleElement"
Fill
=
"Green"
Data
=
"{TemplateBinding ItemGeometry}"
/>
<
Path
Data
=
"M108.5,54.25C108.5,84.211448 84.211448,108.5 54.25,108.5 24.288552,108.5 0,84.211448 0,54.25 0,24.288552 24.288552,0 54.25,0 84.211448,0 108.5,24.288552 108.5,54.25z"
Height
=
"{TemplateBinding Diameter}"
Canvas.Left
=
"{TemplateBinding Left}"
Stretch
=
"Fill"
SnapsToDevicePixels
=
"True"
Stroke
=
"Transparent"
StrokeThickness
=
"0"
Canvas.Top
=
"{TemplateBinding Top}"
Width
=
"{TemplateBinding Diameter}"
>
<
Path.Fill
>
<
RadialGradientBrush
GradientOrigin
=
"0.5,0.5"
>
<
GradientStop
Color
=
"#66FFFFFF"
Offset
=
"0.86"
/>
<
GradientStop
Color
=
"Transparent"
Offset
=
"0.85"
/>
<
GradientStop
Color
=
"#26FFFFFF"
/>
</
RadialGradientBrush
>
</
Path.Fill
>
</
Path
>
</
Canvas
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
UserControl.Resources
>
<
telerik:RadChart
SnapsToDevicePixels
=
"True"
FontSize
=
"9"
Height
=
"200"
Width
=
"400"
ItemsSource
=
"{Binding Source={StaticResource SampleDataSource}, Path=Collection}"
>
<
telerik:RadChart.DefaultView
>
<
telerik:ChartDefaultView
>
<
telerik:ChartDefaultView.ChartArea
>
<
telerik:ChartArea
NoDataString
=
"Isufficient Information"
Style
=
"{StaticResource ChartAreaStyle}"
>
<
telerik:ChartArea.AxisY
>
<
telerik:AxisY
TextBlock.Foreground
=
"LightGray"
MinorTickPointMultiplier
=
"5"
ExtendDirection
=
"Up"
MajorGridLinesVisibility
=
"Visible"
MinorTicksVisibility
=
"Hidden"
DefaultLabelFormat
=
"0"
>
</
telerik:AxisY
>
</
telerik:ChartArea.AxisY
>
<
telerik:ChartArea.AxisX
>
<
telerik:AxisX
MinValue
=
"0"
TextBlock.Foreground
=
"LightGray"
IsZeroBased
=
"True"
LayoutMode
=
"Auto"
TextBlock.FontSize
=
"5"
MajorGridLinesVisibility
=
"Visible"
MinorTicksVisibility
=
"Hidden"
>
</
telerik:AxisX
>
</
telerik:ChartArea.AxisX
>
</
telerik:ChartArea
>
</
telerik:ChartDefaultView.ChartArea
>
</
telerik:ChartDefaultView
>
</
telerik:RadChart.DefaultView
>
<
telerik:RadChart.SeriesMappings
>
<
telerik:SeriesMapping
>
<
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:BubbleSeriesDefinition
BubbleSizeRelative
=
"False"
ItemStyle
=
"{StaticResource CustomBubbleStyle}"
/>
</
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:SeriesMapping.ItemMappings
>
<
telerik:ItemMapping
DataPointMember
=
"XValue"
FieldName
=
"XValue"
/>
<
telerik:ItemMapping
DataPointMember
=
"YValue"
FieldName
=
"YValue"
/>
<
telerik:ItemMapping
DataPointMember
=
"Label"
FieldName
=
"ID"
/>
</
telerik:SeriesMapping.ItemMappings
>
</
telerik:SeriesMapping
>
<!-- Regression Line -->
<
telerik:SeriesMapping
ItemsSource
=
"{Binding Source={StaticResource RegressionLine}, Path=Collection}"
>
<
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:LineSeriesDefinition
/>
</
telerik:SeriesMapping.SeriesDefinition
>
<
telerik:ItemMapping
DataPointMember
=
"XValue"
FieldName
=
"Property1"
/>
<
telerik:ItemMapping
DataPointMember
=
"YValue"
FieldName
=
"Property2"
/>
</
telerik:SeriesMapping
>
</
telerik:RadChart.SeriesMappings
>
</
telerik:RadChart
>
</
UserControl
>
///This is the xaml code for defining the grid columns and style for List View
<
telerik:RadBusyIndicator
DisplayAfter
=
"0"
x:Name
=
"radBusyIndicator"
Background
=
"Transparent"
HorizontalContentAlignment
=
"Stretch"
VerticalContentAlignment
=
"Stretch"
>
<
telerik:RadGridView
Name
=
"grid"
IsReadOnly
=
"True"
CanUserDeleteRows
=
"False"
CanUserInsertRows
=
"False"
CanUserSortColumns
=
"False"
ColumnWidth
=
"*"
Height
=
"Auto"
Width
=
"Auto"
ItemsSource
=
"{Binding}"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Name
=
"agentCodeCol"
DataMemberBinding
=
"{Binding AgentCode}"
HeaderTextAlignment
=
"Right"
TextAlignment
=
"Right"
Header
=
"Agent Code"
/>
<
telerik:GridViewDataColumn
Name
=
"lastNameCol"
DataMemberBinding
=
"{Binding LastName}"
Header
=
"Last Name"
/>
<
telerik:GridViewDataColumn
Name
=
"firstNameCol"
DataMemberBinding
=
"{Binding FirstName}"
Header
=
"First Name"
/>
<
telerik:GridViewDataColumn
Name
=
"cityCol"
DataMemberBinding
=
"{Binding city}"
Header
=
"City"
/>
<
telerik:GridViewDataColumn
Name
=
"stateCol"
DataMemberBinding
=
"{Binding StateCode}"
Header
=
"State"
/>
<
telerik:GridViewDataColumn
Name
=
"zipCol"
DataMemberBinding
=
"{Binding Zip}"
Header
=
"ZIP"
TextAlignment
=
"Right"
HeaderTextAlignment
=
"Right"
/>
<
telerik:GridViewDataColumn
Name
=
"editProfileCol"
Header
=
"Edit Profile"
HeaderTextAlignment
=
"Center"
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
Button
x:Name
=
"editProfileBtn"
Content
=
"Edit"
Click
=
"OnEditProfileBtnClick"
Width
=
"70"
Height
=
"16"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
Name
=
"swapInCol"
Header
=
"Swap In"
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
Button
Content
=
"Swap In"
Style
=
"{StaticResource buttonStyle}"
Click
=
"OnSwapInBtnClick"
Width
=
"70"
Height
=
"16"
/>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
telerik:RadBusyIndicator
>
<
Style
x:Key
=
"lvStyle"
TargetType
=
"{x:Type ListView}"
>
<
Setter
Property
=
"VirtualizingStackPanel.IsVirtualizing"
Value
=
"True"
/>
<
Setter
Property
=
"VirtualizingStackPanel.VirtualizationMode"
Value
=
"Recycling"
/>
<
Setter
Property
=
"ScrollViewer.IsDeferredScrollingEnabled"
Value
=
"True"
/>
<
Setter
Property
=
"ListView.ItemsSource"
Value
=
"{Binding}"
/>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding IsLoading}"
Value
=
"True"
>
<
Setter
Property
=
"ListView.Cursor"
Value
=
"Wait"
/>
<
Setter
Property
=
"ListView.Background"
Value
=
"LightGray"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
//Code for binding the grid using VirtualQueryableCollectionView
DataTable totalRowCountDT = searchResDS.Tables[0]; //Getting the table from Database
if (totalRowCountDT != null && totalRowCountDT.Rows.Count > 0 && totalRowCountDT.Rows[0][0] != DBNull.Value) {
int numItems = Convert.ToInt32(totalRowCountDT.Rows[0][0]);
AgentProvider agentProvider = new AgentProvider(numItems, 0);
var view = new VirtualQueryableCollectionView<
Agent
>() { LoadSize = 500, VirtualItemCount = agentProvider.FetchCount() };
view.ItemsLoading += (s, args) => {
ShowOrHideProgressBar(true);
view.Load(args.StartIndex, agentProvider.FetchRange(args.StartIndex, args.ItemCount));
ShowOrHideProgressBar(false);
};
grid.DataContext = view;
//Method to show and hide the RadBusyIndicator
public void ShowOrHideProgressBar(bool showOrHide) {
this.radBusyIndicator.IsBusy = showOrHide;
}
//Class to provide data for Grid to while scrolling
public class AgentProvider : IItemsProvider<
Agent
> {
private readonly int _count;
private readonly int _fetchDelay;
/// <
summary
>
/// Initializes a new instance of the <
see
cref
=
"DemoCustomerProvider"
/> class.
/// </
summary
>
/// <
param
name
=
"count"
>The count.</
param
>
/// <
param
name
=
"fetchDelay"
>The fetch delay.</
param
>
public AgentProvider(int count, int fetchDelay) {
_count = count;
_fetchDelay = fetchDelay;
}
/// <
summary
>
/// Fetches the total number of items available.
/// </
summary
>
/// <
returns
></
returns
>
public int FetchCount() {
Trace.WriteLine("FetchCount");
return _count;
}
/// <
summary
>
/// Fetches a range of items.
/// </
summary
>
/// <
param
name
=
"startIndex"
>The start index.</
param
>
/// <
param
name
=
"count"
>The number of items to fetch.</
param
>
/// <
returns
></
returns
>
public IList<
Agent
> FetchRange(int startIndex, int count) {
Trace.WriteLine("FetchRange: " + startIndex + "," + count);
AgentEntity agentEntity = new AgentEntity();
DataSet searchResDS = agentEntity.GetAllAgentDetails(
VirtualizationHelper.AgetStruct.LastName
, VirtualizationHelper.AgetStruct.FirstName
, VirtualizationHelper.AgetStruct.AgentCode
, VirtualizationHelper.AgetStruct.Email
, VirtualizationHelper.AgetStruct.Phone
, VirtualizationHelper.AgetStruct.Zip
, VirtualizationHelper.AgetStruct.StateId
, VirtualizationHelper.AgetStruct.UserId
, VirtualizationHelper.AgetStruct.IsCurrentUsrHomeOffUsr
, startIndex
, startIndex+count
, UserInfo.IsCurrentUserLoggedInUser);
DataTable agenttDT = searchResDS.Tables[1];
List<
Agent
> list = new List<
Agent
>();
foreach (DataRow row in agenttDT.Rows) {
Agent agent = new Agent {
AgentCode = Convert.ToString(row["AgentCode"])
, LastName = Convert.ToString(row["LastName"])
, FirstName = Convert.ToString(row["FirstName"])
, city = Convert.ToString(row["city"])
, StateCode = Convert.ToString(row["StateCode"])
, Zip = Convert.ToString(row["Zip"])
, GACode = Convert.ToString(row["GACode"])
, AgentGuid = Convert.ToString(row["AgentGuid"])
};
list.Add(agent);
}
return list;
}
}
<
telerik:RadWindow
x:Class
=
"RadToolBar.View"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"550"
>
<
Grid
>
<
StackPanel
>
<
telerik:RadToolBar
>
<
telerik:RadComboBox
Name
=
"graphModes"
Width
=
"250"
Height
=
"22"
Margin
=
"3"
>
<
ComboBoxItem
>One</
ComboBoxItem
>
<
ComboBoxItem
>Two</
ComboBoxItem
>
<
ComboBoxItem
>Three</
ComboBoxItem
>
</
telerik:RadComboBox
>
</
telerik:RadToolBar
>
</
StackPanel
>
</
Grid
>
</
telerik:RadWindow
>
If using normal Window - all working nice. But i want use RadWindow!