internal void AddItem(RadzenTreeItem item) { if (items.IndexOf(item) == -1) { items.Add(item); } }
internal void RemoveItem(RadzenTreeItem item) { if (items.IndexOf(item) != -1) { items.Remove(item); } }
internal async Task ExpandItem(RadzenTreeItem item) { var args = new TreeExpandEventArgs() { Text = item?.Text, Value = item?.Value, Children = new TreeItemSettings() }; await Expand.InvokeAsync(args); if (args.Children.Data != null) { var childContent = new RenderFragment(builder => { Func <object, string> text = null; var children = args.Children; foreach (var data in children.Data) { if (text == null) { text = children.Text ?? Getter <string>(data, children.TextProperty); } RenderTreeItem(builder, data, children.Template, text, children.HasChildren, children.Expanded, children.Selected); builder.CloseComponent(); } }); item.RenderChildContent(childContent); if (AllowCheckBoxes && AllowCheckChildren && args.Children.Data != null) { if (CheckedValues != null && CheckedValues.Contains(item.Value)) { await SetCheckedValues(CheckedValues.Union(args.Children.Data.Cast <object>().Except(UncheckedValues))); } else { await SetCheckedValues(CheckedValues.Except(args.Children.Data.Cast <object>())); } } } else if (item.Data != null) { if (AllowCheckBoxes && AllowCheckChildren && item.Data != null) { if (CheckedValues != null && CheckedValues.Contains(item.Value)) { await SetCheckedValues(CheckedValues.Union(item.Data.Cast <object>().Except(UncheckedValues))); } else { await SetCheckedValues(CheckedValues); } } } }
internal bool Contains(RadzenTreeItem child) { var parent = child.ParentItem; while (parent != null) { if (parent == this) { return(true); } parent = parent.ParentItem; } return(false); }
internal async Task SelectItem(RadzenTreeItem item) { var selectedItem = SelectedItem; if (selectedItem != item) { SelectedItem = item; selectedItem?.Unselect(); if (Value != item.Value) { await ValueChanged.InvokeAsync(item.Value); } await Change.InvokeAsync(new TreeEventArgs() { Text = item?.Text, Value = item?.Value }); } }