Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CS/App.ico
Binary file not shown.
7 changes: 7 additions & 0 deletions CS/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Application x:Class="OnDemandLoading.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
StartupUri="MainWindow.xaml">
<Application.Resources />
</Application>
26 changes: 26 additions & 0 deletions CS/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#region Copyright Syncfusion Inc. 2001 - 2015
// Copyright Syncfusion Inc. 2001 - 2015. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace OnDemandLoading
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
}
}
}
47 changes: 47 additions & 0 deletions CS/Behavior/RequestTreeItemsBehavior.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.Xaml.Behaviors;
using Syncfusion.UI.Xaml.Grid;
using Syncfusion.UI.Xaml.TreeGrid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnDemandLoading
{
class RequestTreeItemsBehavior : Behavior<SfTreeGrid>
{
ViewModel viewModel;
protected override void OnAttached()
{
base.OnAttached();
viewModel = this.AssociatedObject.DataContext as ViewModel;
this.AssociatedObject.RequestTreeItems += AssociatedObject_RequestTreeItems;

}

void AssociatedObject_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
{
if (args.ParentItem == null)
{
//get the root list - get all employees who have no boss
args.ChildItems = viewModel.EmployeeDetails.Where(x => x.ReportsTo == -1); //get all employees whose boss's id is -1 (no boss)
}
else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
{ //get the children of the parent object
EmployeeInfo emp = args.ParentItem as EmployeeInfo;
if (emp != null)
{
//get all employees that report to the parent employee
args.ChildItems = viewModel.GetReportees(emp.ID);
}
}
}

protected override void OnDetaching()
{
base.OnDetaching();
this.AssociatedObject.RequestTreeItems -= AssociatedObject_RequestTreeItems;
}
}
}
34 changes: 34 additions & 0 deletions CS/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<syncfusion:ChromelessWindow x:Class="OnDemandLoading.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:OnDemandLoading"
xmlns:interactivity="http://schemas.microsoft.com/xaml/behaviors"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
Icon="App.ico"
WindowStartupLocation="CenterScreen">
<syncfusion:ChromelessWindow.DataContext>
<local:ViewModel />
</syncfusion:ChromelessWindow.DataContext>

<Grid>
<syncfusion:SfTreeGrid Name="treeGrid"
AutoGenerateColumns="False"
ItemsSource="{Binding EmployeeDetails}">
<interactivity:Interaction.Behaviors>
<local:RequestTreeItemsBehavior />
</interactivity:Interaction.Behaviors>

<syncfusion:SfTreeGrid.Columns>
<syncfusion:TreeGridTextColumn HeaderText="First Name" MappingName="FirstName" />
<syncfusion:TreeGridTextColumn HeaderText="Employee ID"
MappingName="ID"
TextAlignment="Left" />

<syncfusion:TreeGridTextColumn HeaderText="Last Name" MappingName="LastName" />
<syncfusion:TreeGridTextColumn MappingName="Title" />
<syncfusion:TreeGridCurrencyColumn MappingName="Salary" />
<syncfusion:TreeGridTextColumn HeaderText="Reports To" MappingName="ReportsTo" />
</syncfusion:SfTreeGrid.Columns>
</syncfusion:SfTreeGrid>
</Grid>
</syncfusion:ChromelessWindow>
35 changes: 35 additions & 0 deletions CS/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#region Copyright Syncfusion Inc. 2001 - 2016
// Copyright Syncfusion Inc. 2001 - 2016. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using Syncfusion.Windows.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OnDemandLoading
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : ChromelessWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
159 changes: 159 additions & 0 deletions CS/Model/EmployeeInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#region Copyright Syncfusion Inc. 2001 - 2016
// Copyright Syncfusion Inc. 2001 - 2016. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Syncfusion.Windows.Shared;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace OnDemandLoading
{
public class EmployeeInfo : NotificationObject//, IComparable<EmployeeInfo>
{
int _id;
/// <summary>
/// Gets or sets the ID.
/// </summary>
/// <value>The ID.</value>
public int ID
{
get
{
return _id;
}
set
{
_id = value;
RaisePropertyChanged("ID");
}
}
string _firstName;

/// <summary>
/// Gets or sets the first name.
/// </summary>
/// <value>The first name.</value>
public string FirstName
{
get
{
return _firstName;
}
set
{
_firstName = value;
RaisePropertyChanged("FirstName");
}
}
string _lastName;

/// <summary>
/// Gets or sets the last name.
/// </summary>
/// <value>The last name.</value>
public string LastName
{
get
{
return _lastName;
}
set
{
_lastName = value;
RaisePropertyChanged("LastName");
}
}
string _department;

/// <summary>
/// Gets or sets the department.
/// </summary>
/// <value>The department.</value>
public string Department
{
get
{
return _department;
}
set
{
_department = value;
RaisePropertyChanged("Department");
}
}
private string _title;

/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>The title.</value>
public string Title
{
get
{
return _title;
}
set
{
_title = value;
RaisePropertyChanged("Title");
}
}

double? _salary;
/// <summary>
/// Gets or sets the salary.
/// </summary>
/// <value>The salary.</value>
public double? Salary
{
get
{
return _salary;
}
set
{
_salary = value;
RaisePropertyChanged("Salary");
}
}

int _reportsTo;
/// <summary>
/// Gets or sets the reports to.
/// </summary>
/// <value>The reports to.</value>
public int ReportsTo
{
get
{
return _reportsTo;
}
set
{
_reportsTo = value;
RaisePropertyChanged("ReportsTo");
}
}

#region IComparable<Employee> Members

//public int CompareTo(EmployeeInfo other)
//{
// // return this.reportsTo - other.reportsTo;
// if (other == null)
// return -1;

// return this.ReportsTo.CompareTo(other.ReportsTo);
//}

#endregion
}
}
Loading