@@ -44,9 +44,6 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
4444 Draggable="true"
4545 OnDragStart="@OnDragStart"
4646 OnDrop="@TreeViewDropHandler">
47- <TreeViewBindings>
48- <TreeViewBinding ParentIdField="Parent"></TreeViewBinding>
49- </TreeViewBindings>
5047</TelerikTreeView>
5148
5249@* <TelerikSvgIcon Icon="@SvgIcon.Plus"></TelerikSvgIcon> - Render the desired icon to get its path. *@
@@ -56,10 +53,10 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
5653 @onpointerenter="@((PointerEventArgs args) => IsPointerOverCustomTarget = true)"
5754 @onpointerout="@((PointerEventArgs args) => IsPointerOverCustomTarget = false)">
5855
59- @foreach (var item in DroppedItems)
56+ @foreach (var item in DroppedItems)
6057 {
61- @item.Text
62- <br/>
58+ @item.Text
59+ <br />
6360 }
6461</div>
6562
@@ -83,8 +80,8 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
8380
8481@code {
8582 private TreeItem DraggedtItem { get; set; }
86- private List<TreeItem> Data { get; set; }
87- private IEnumerable<object> ExpandedItems { get; set; }
83+ private List<TreeItem> Data { get; set; } = new List<TreeItem>();
84+ private IEnumerable<object> ExpandedItems { get; set; } = Enumerable.Empty<object>();
8885 private List<TreeItem> DroppedItems { get; set; } = new List<TreeItem>();
8986 private bool IsPointerOverCustomTarget { get; set; }
9087 private bool IsItemAlreadyInCustomTarget { get; set; }
@@ -100,10 +97,10 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
10097 private void CustomTargetDropHandler()
10198 {
10299 if (DraggedtItem != null && !IsItemAlreadyInCustomTarget)
103- {
100+ {
104101 DroppedItems.Add(DraggedtItem);
105102 }
106- }
103+ }
107104
108105 private void TreeViewDropHandler(TreeViewDropEventArgs args)
109106 {
@@ -117,14 +114,14 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
117114
118115 Data.Remove(item);
119116
120- if (item.Parent != null && !Data.Any(x => item.Parent == x.Parent ))
117+ if (item.ParentId != null && !Data.Any(x => item.ParentId == x.ParentId ))
121118 {
122- Data.FirstOrDefault(x => x.Id == item.Parent ).HasChildren = false;
119+ Data.FirstOrDefault(x => x.Id == item.ParentId ).HasChildren = false;
123120 }
124121
125122 if (args.DropPosition == TreeViewDropPosition.Over)
126123 {
127- item.Parent = destinationItem.Id;
124+ item.ParentId = destinationItem.Id;
128125 destinationItem.HasChildren = true;
129126
130127 Data.Add(item);
@@ -133,7 +130,7 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
133130 {
134131 var index = Data.IndexOf(destinationItem);
135132
136- item.Parent = destinationItem.Parent ;
133+ item.ParentId = destinationItem.ParentId ;
137134
138135 if (args.DropPosition == TreeViewDropPosition.After)
139136 {
@@ -149,16 +146,16 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
149146
150147 private bool IsChild(TreeItem item, TreeItem destinationItem)
151148 {
152- if (destinationItem?.Parent == null || item == null)
149+ if (destinationItem?.ParentId == null || item == null)
153150 {
154151 return false;
155152 }
156- else if (destinationItem.Parent ?.Equals(item.Id) == true)
153+ else if (destinationItem.ParentId ?.Equals(item.Id) == true)
157154 {
158155 return true;
159156 }
160157
161- var parentDestinationItem = Data.FirstOrDefault(e => e.Id.Equals(destinationItem.Parent ));
158+ var parentDestinationItem = Data.FirstOrDefault(e => e.Id.Equals(destinationItem.ParentId ));
162159
163160 return IsChild(item, parentDestinationItem);
164161 }
@@ -191,15 +188,15 @@ To allow dragging outside the TreeView and dropping on a custom target, follow t
191188 public class TreeItem
192189 {
193190 public int Id { get; set; }
194- public int? Parent { get; set; }
191+ public int? ParentId { get; set; }
195192 public string Text { get; set; }
196193 public ISvgIcon Icon { get; set; }
197194 public bool HasChildren { get; set; }
198195
199196 public TreeItem(int id, int? parent, string text, ISvgIcon icon, bool hasChildren)
200197 {
201198 Id = id;
202- Parent = parent;
199+ ParentId = parent;
203200 Text = text;
204201 Icon = icon;
205202 HasChildren = hasChildren;
0 commit comments