Hello all,
I need a scenario in which the item template of OrgChartNodeLayout(in GlobalNodeLayouts) needs to be different based on some conditions.
For example:
<ig:XamOrgChart.GlobalNodeLayouts> <ig:OrgChartNodeLayout TargetTypeName="Department" DisplayMemberPath="DepartmentName" Key="Departments" /></ig:XamOrgChart.GlobalNodeLayouts>
In above example, suppose if Department has sub-Departments, then, one template should be used.
But if that Department doesn't have Sub-Departments,instead ,has Employees, then other template should be used.
The class structure for Department class is :
public class Department { public Department(string name) { this.DepartmentName =name; this.Departments = new ObservableCollection<Department>(); this.Employees = new ObservableCollection<Employee>(); }
public string DepartmentName { get; set; }
public ObservableCollection<Department> Departments { get; set; } public ObservableCollection<Employee> Employees { get; set; } }
If Department has Sub-Departments, the Departments(Observable collection) will have value [Count > 1] and if it doesn't have Sub-Department, then the Employees will have value [Count > 1].
How can I achieve different Item Template based on above conditions? [For List Box , there is itemTemplateSelector, is there any similar approach in this one? ]
Thank you in advance for your time.
Help..
Hello,
One option to set the item template on the XamOrgChart based on certain conditions is to create some OrgChartNodeLayouts and set the DisplayMemberPath, TargetTypeName, and Key in code-behind.
Then, use an if-else statement to check to see if a certain collection in your datasource has a count greater than 0 and if so, add the corresponding OrgChartNodeLayout to the XamOrgChart.GlobalNodeLayouts collection.
I have attached a sample demonstrating the above.
If the sample I have attached is not sufficient to solve this issue in the way that you had expected, please respond with more information so I can modify it to suit your needs.
Sincerely,AndrewDeveloper Support IInfragistics Inc.www.infragistics.com/support
I have added the desired behavior in the snapshot .please check the attached sanps.
And.
Thanks for the reply. But sadly, it didn't satisfy what i needed. Actually, I already tried with having separate "Sub-Department" class. But my requirement contains only "Department" class containing Departments and Employee information. If "Department" object contains Sub-Departments, then it's Property "Departments" will have collection of sub-department objects , and the Department contains Employees, then it's Property "Employees" will have Employee object. At a time, Department object can't have value in both "Departments" and "Employees".
Actually, I need it for Drag & Drop Framework. So that the Sub-Department's can be moved to other Department as well.
For Example:
If A Department has child B Department and C Department.
And, B Department has child D Department which holds many employees.
And, I need to move (using drag & drop framework) D Department to A department.
Therefore, the final scenario will be.
A Department has Child B Department ,C Department and D department. whereas D department has only Employees.
Therefore, my requirement is :
Display only Department Name for Department having Departments but no Employee Information (Using one template : I already created template)
Display Employee information (in ListBox) with Department Name for Sub-Department which have Employee Information (Using other template: i have made that too.)
So, is it possible to have two separate template for same type of Node depending on conditions? Does my explanation above make any sense? If not, please write me further.
Thank you once again.
Best Regards,
Ram