/// <summary> /// Handles the RequestTreeItems event of the grid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> static void grid_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { GridTreeControl gridTree = sender as GridTreeControl; //code showing how to use LoadAllAtStartUp property.... if (gridTree.InternalGrid.LoadAllAtStartUp && args.ParentItem == null) { //need to load all the GridNodes into g.Nodes.... IEnumerable <EmployeeInfo> rootNodes = viewModel.GetReportees(-1); foreach (EmployeeInfo e in rootNodes) { gridTree.InternalGrid.RootNodes.Add(Populate(gridTree, e, null, 0, null)); } return; } if (args.ParentItem == null) { //get the root list - get all employees who have no boss args.ChildList = viewModel.GetReportees(-1); //get all employees whose boss's id is -1 (no boss) } else { //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.ChildList = viewModel.GetReportees(emp.ID); } } }
/// <summary> /// Handles the RequestTreeItems event of the AssociatedObject control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> void AssociatedObject_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { //when ParentItem is null, you need to set args.ChildList to be the root items... if (args.ParentItem == null) { args.ChildList = (IEnumerable)viewModel.DriveDetails; } else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem. { FileInfoModel item = args.ParentItem as FileInfoModel; args.ChildList = viewModel.GetChildFolderContent(item); } }
/// <summary> /// Handles the RequestTreeItems event of the AssociatedObject control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> void AssociatedObject_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { //when ParentItem is null, you need to set args.ChildList to be the root items... if (args.ParentItem == null) //requesting the root list... { //get all employees whose boss's id is -1 (no boss) EmployeesDataSet.EmployeesDataTable dt = viewModel.dataAdapter.GetReportees(-1); args.ChildList = dt.DefaultView; } else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem. { //get the children of the parent object DataRowView drv = args.ParentItem as DataRowView; EmployeesDataSet.EmployeesDataTable dt = viewModel.dataAdapter.GetReportees((int)drv["ID"]); args.ChildList = dt.DefaultView; //get all employees whose boss's id is -1 (no boss) } }
/// <summary> /// Handles the RequestTreeItems event of the AssociatedObject control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> void AssociatedObject_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { if (args.ParentItem == null) { //get the root list - get all employees who have no boss args.ChildList = 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.ChildList = viewModel.GetReportees(emp.ID); } } }
/// <summary> /// Handles the RequestTreeItems event of the InternalGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> void InternalGrid_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { //when ParentItem is null, you need to set args.ChildList to be the root items... if (args.ParentItem == null) { //get the root list - get all employees who have no boss //get all employees whose boss's id is -1 (no boss) args.ChildList = viewModel.CarDetails.Where(x => x.ReportsTo == -1); } else //if ParentItem not null, then set args.ChildList to the child items for the given ParentItem. { //get the children of the parent object CarInfo car = args.ParentItem as CarInfo; if (car != null) { //get all employees that report to the parent employee args.ChildList = viewModel.CarDetails.Where(x => x.ReportsTo == car.ID); } } }
/// <summary> /// Handles the RequestTreeItems event of the AssociatedObject control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="args">The <see cref="Syncfusion.Windows.Controls.Grid.GridTreeRequestTreeItemsEventArgs"/> instance containing the event data.</param> void AssociatedObject_RequestTreeItems(object sender, GridTreeRequestTreeItemsEventArgs args) { //if (viewModel != null) //{ //when ParentItem is null, you need to set args.ChildList to be the root items... if (args.ParentItem == null) { //get the root list - get all employees who have no boss args.ChildList = (this.AssociatedObject.DataContext as ViewModel).GetReportees(-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.ChildList = (this.AssociatedObject.DataContext as ViewModel).GetReportees(emp.ID); } } //} }