Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Select different ItemTemplate in OrgChartNodeLayout depending on conditions
posted

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..

Parents
  • 34810
    Offline posted

    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,
    Andrew
    Developer Support I
    Infragistics Inc.
    www.infragistics.com/support

    XamOrgChartDifferentItemTemplateCase.zip
Reply Children