I created a treeview, because I had designated ItemsOptionListType="CheckList", so there is a checkbox next to every node. But I need to check the checkbox according to different datasets(Receiver Object collection), so how can I achieve this feature through binding?
Here is my Class:
public class Receiver |
{ |
public Receiver() { } |
[Key] |
public int AdminId { get; set; } |
public string AdminName { get; set; } |
public int TeamId { get; set; } |
public string TeamName { get; set; } |
} |
Here is my tree:
<riaControls:DomainDataSource x:Name="DDS_OrgOrderList" | |||||||
AutoLoad="False" | |||||||
QueryName="GetOrganizationListByIDQuery" | |||||||
LoadedData="DDS_OrgOrderList_LoadedData"> | |||||||
<riaControls:DomainDataSource.DomainContext> | |||||||
<localWeb:MessageContext/> | |||||||
</riaControls:DomainDataSource.DomainContext> | |||||||
<riaControls:DomainDataSource.QueryParameters> | |||||||
<riaData:Parameter ParameterName="orgID"/> | |||||||
</riaControls:DomainDataSource.QueryParameters> | |||||||
</riaControls:DomainDataSource> <core:HierarchicalDataTemplate x:Key="Org" ItemsSource="{Binding Orgs}"> <StackPanel Orientation="Horizontal"> <Image Source="{Binding Image}" Margin=" 0,0,6,0" /> <TextBlock Text="{Binding ID}" Margin=" 0,0,6,0" FontSize="12" /> <TextBlock Text="{Binding Name}" FontSize="12" /> </StackPanel> </core:HierarchicalDataTemplate> |
<telerikNavigation:RadTreeView SelectionMode="Extended" IsLineEnabled="True" ItemsOptionListType="CheckList" IsOptionElementsEnabled="True" IsRootLinesEnabled="True" SelectionChanged="OrgTree_SelectionChanged" Selected="OrgTree_Selected" Checked="OrgTree_Checked" Unchecked="OrgTree_Unchecked" |
HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" x:Name="OrgTree" IsTriStateMode="True" ItemTemplate="{StaticResource Org}" |
Expanded="OrgTree_Expanded" PreviewExpanded="OrgTree_PreviewExpanded"/> |
public void DDS_OrgOrderList_LoadedData(object sender, LoadedDataEventArgs e) |
{ |
var myOrgLists = e.Entities; |
Member m = new Member(); |
Org _root; |
Org _pOrg; |
Org _cOrg; |
m.Add(_root = new Org(1, "root", 1, 0, "0",null,"")); |
int _level = 0; |
_pOrg = _root; |
foreach (OrgOrderList anOrg in myOrgLists) |
{ |
if (anOrg.treepath.Length == 1) |
{ |
continue; |
} |
else if (anOrg.level != _level) |
{ |
for (int f = 1; f < (anOrg.treepath.Length - 1) / 8; f++) |
{ |
int _index = Int32.Parse(anOrg.treepath.Substring(1 + (f-1) * 8, 8)) - 1; |
_pOrg = _pOrg.Orgs[_index]; |
} |
} |
_level = anOrg.level; |
_cOrg = new Org(anOrg.orgID, anOrg.orgName, (int)anOrg.orgTypeID, anOrg.level, anOrg.treepath,anOrg.personID,anOrg.pName); |
_pOrg.Orgs.Add(_cOrg); |
} |
OrgTree.ItemsSource = m; |
} |