Skip to content

Commit e26bfe1

Browse files
author
Sampath Narayanan
committed
Sample for On-Demand loading has been committed.
1 parent 26d8b60 commit e26bfe1

18 files changed

+1045
-0
lines changed

CS/App.ico

4.19 KB
Binary file not shown.

CS/App.xaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Application x:Class="OnDemandLoading.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources />
7+
</Application>

CS/App.xaml.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#region Copyright Syncfusion Inc. 2001 - 2015
2+
// Copyright Syncfusion Inc. 2001 - 2015. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Configuration;
11+
using System.Data;
12+
using System.Linq;
13+
using System.Windows;
14+
15+
namespace OnDemandLoading
16+
{
17+
/// <summary>
18+
/// Interaction logic for App.xaml
19+
/// </summary>
20+
public partial class App : Application
21+
{
22+
public App()
23+
{
24+
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Syncfusion.Licensing.DemoCommon.FindLicenseKey());
25+
}
26+
}
27+
}

CS/Commands/CollapseCommand.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#region Copyright Syncfusion Inc. 2001-2016.
2+
// Copyright Syncfusion Inc. 2001-2016. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Text;
12+
using System.Windows.Input;
13+
using Syncfusion.Windows.Controls.Grid;
14+
using Syncfusion.UI.Xaml.TreeGrid;
15+
16+
namespace OnDemandLoading
17+
{
18+
public static class CollapseCommand
19+
{
20+
static CollapseCommand()
21+
{
22+
CommandManager.RegisterClassCommandBinding(typeof(SfTreeGrid), new CommandBinding(CollapseAll, OnExecuteCollapseAll));
23+
}
24+
25+
public static RoutedCommand CollapseAll = new RoutedCommand("CollapseAll", typeof(SfTreeGrid));
26+
27+
/// <summary>
28+
/// Called when [execute collapse all].
29+
/// </summary>
30+
/// <param name="sender">The sender.</param>
31+
/// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
32+
private static void OnExecuteCollapseAll(object sender, ExecutedRoutedEventArgs args)
33+
{
34+
SfTreeGrid treeGrid = args.Source as SfTreeGrid;
35+
treeGrid.CollapseAllNodes();
36+
}
37+
}
38+
}

CS/Commands/ExpandCommand.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#region Copyright Syncfusion Inc. 2001-2016.
2+
// Copyright Syncfusion Inc. 2001-2016. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using System;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Text;
12+
using System.Windows.Input;
13+
using Syncfusion.Windows.Controls.Grid;
14+
using Syncfusion.UI.Xaml.Grid;
15+
using Syncfusion.UI.Xaml.TreeGrid;
16+
17+
namespace OnDemandLoading
18+
{
19+
public static class ExpandCommand
20+
{
21+
/// <summary>
22+
/// Initializes the <see cref="ExpandCommand"/> class.
23+
/// </summary>
24+
static ExpandCommand()
25+
{
26+
CommandManager.RegisterClassCommandBinding(typeof(SfTreeGrid), new CommandBinding(ExpandAll, OnExecuteExpandAll));
27+
}
28+
29+
public static RoutedCommand ExpandAll = new RoutedCommand("ExpandAll", typeof(SfTreeGrid));
30+
31+
/// <summary>
32+
/// Called when [execute expand all].
33+
/// </summary>
34+
/// <param name="sender">The sender.</param>
35+
/// <param name="args">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
36+
private static void OnExecuteExpandAll(object sender, ExecutedRoutedEventArgs args)
37+
{
38+
SfTreeGrid treeGrid = args.Source as SfTreeGrid;
39+
treeGrid.ExpandAllNodes();
40+
}
41+
}
42+
}

CS/Commands/LoadCommand.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Syncfusion.UI.Xaml.TreeGrid;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Collections.Specialized;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using System.Windows.Input;
9+
10+
namespace OnDemandLoading.Commands
11+
{
12+
class LoadCommand : ICommand
13+
{
14+
public event EventHandler CanExecuteChanged;
15+
16+
public bool CanExecute(object parameter)
17+
{
18+
TreeNode node = (parameter as TreeNode);
19+
EmployeeInfo emp = node.Item as EmployeeInfo;
20+
if (emp != null)
21+
if (emp.ReportsTo == -1 || emp.ReportsTo == 34 || emp.ReportsTo == 36 || emp.ReportsTo == 65)
22+
return true;
23+
return false;
24+
}
25+
26+
public void Execute(object parameter)
27+
{
28+
TreeNode node = (parameter as TreeNode);
29+
30+
EmployeeInfo emp = node.Item as EmployeeInfo;
31+
if (emp != null)
32+
{
33+
node.PopulateChildNodes((App.Current.MainWindow.DataContext as ViewModel).GetReportees(emp.ID));
34+
}
35+
}
36+
}
37+
}

CS/MainWindow.xaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<syncfusion:ChromelessWindow x:Class="OnDemandLoading.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:I="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
5+
xmlns:local="clr-namespace:OnDemandLoading"
6+
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
7+
syncfusion:LayoutControl.SetMetroMode="True"
8+
Icon="App.ico"
9+
WindowStartupLocation="CenterScreen">
10+
<syncfusion:ChromelessWindow.DataContext>
11+
<local:ViewModel />
12+
</syncfusion:ChromelessWindow.DataContext>
13+
14+
<Grid>
15+
<syncfusion:LayoutControl HeaderDescriptionText="This sample exposes the On-demand loading of SfTreeGrid."
16+
HeaderText="On-demand Loading"
17+
LayoutMode="Metro"
18+
UserOptionsVisibility="Visible">
19+
<syncfusion:LayoutControl.GridView>
20+
<syncfusion:SfTreeGrid Name="treeGrid"
21+
AutoGenerateColumns="False"
22+
LoadOnDemandCommand="{Binding CommandLoad}"
23+
ItemsSource="{Binding EmployeeDetails}">
24+
25+
<syncfusion:SfTreeGrid.Columns>
26+
<syncfusion:TreeGridTextColumn HeaderText="First Name" MappingName="FirstName" />
27+
<syncfusion:TreeGridTextColumn HeaderText="Employee ID"
28+
MappingName="ID"
29+
TextAlignment="Left" />
30+
31+
<syncfusion:TreeGridTextColumn HeaderText="Last Name" MappingName="LastName" />
32+
<syncfusion:TreeGridTextColumn MappingName="Title" />
33+
<syncfusion:TreeGridCurrencyColumn MappingName="Salary" />
34+
<syncfusion:TreeGridTextColumn HeaderText="Reports To" MappingName="ReportsTo" />
35+
</syncfusion:SfTreeGrid.Columns>
36+
37+
</syncfusion:SfTreeGrid>
38+
39+
</syncfusion:LayoutControl.GridView>
40+
<syncfusion:LayoutControl.UserOptionsView>
41+
<syncfusion:UserOptions HeaderText="Options">
42+
<StackPanel x:Name="StkPanel" Margin="6">
43+
<Button Margin="5"
44+
Command="local:ExpandCommand.ExpandAll"
45+
CommandTarget="{Binding GridView,
46+
RelativeSource={RelativeSource Mode=FindAncestor,
47+
AncestorType={x:Type syncfusion:LayoutControl}}}"
48+
Content="Expand All Nodes" />
49+
<Button Margin="5"
50+
Command="local:CollapseCommand.CollapseAll"
51+
CommandTarget="{Binding GridView,
52+
RelativeSource={RelativeSource Mode=FindAncestor,
53+
AncestorType={x:Type syncfusion:LayoutControl}}}"
54+
Content="Collapse All Nodes" />
55+
</StackPanel>
56+
</syncfusion:UserOptions>
57+
</syncfusion:LayoutControl.UserOptionsView>
58+
</syncfusion:LayoutControl>
59+
</Grid>
60+
</syncfusion:ChromelessWindow>

CS/MainWindow.xaml.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#region Copyright Syncfusion Inc. 2001 - 2016
2+
// Copyright Syncfusion Inc. 2001 - 2016. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
using Syncfusion.Windows.Shared;
9+
using System;
10+
using System.Collections.Generic;
11+
using System.Linq;
12+
using System.Text;
13+
using System.Windows;
14+
using System.Windows.Controls;
15+
using System.Windows.Data;
16+
using System.Windows.Documents;
17+
using System.Windows.Input;
18+
using System.Windows.Media;
19+
using System.Windows.Media.Imaging;
20+
using System.Windows.Navigation;
21+
using System.Windows.Shapes;
22+
23+
namespace OnDemandLoading
24+
{
25+
/// <summary>
26+
/// Interaction logic for MainWindow.xaml
27+
/// </summary>
28+
public partial class MainWindow : ChromelessWindow
29+
{
30+
public MainWindow()
31+
{
32+
InitializeComponent();
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)