Is it possible to have the treeview with checkboxes pre-loaded from the db with some checkboxes already checked?
I can't seem to make it work.
Kind regards
Is it possible to have the treeview with checkboxes pre-loaded from the db with some checkboxes already checked?
I can't seem to make it work.
Kind regards
In my case the children aren't selected.
Here's my code
The razor page
<RadzenTree Data=@activities AllowCheckBoxes="true" @bind-CheckedValues=@_checkedValues >
<RadzenTreeLevel TextProperty="Name" ChildrenProperty="Children"
HasChildren=@(e => (e as ApiNotificationActivity).Children.Any()) />
</RadzenTree>
Relevant extracts of the 'code behind':
private IEnumerable<object> checkedValues;
public IEnumerable<object> _checkedValues
{
get => checkedValues;
set
{
checkedValues = value;
}
}
In the onInitialized method:
_checkedValues = new List<object>();
foreach (var activity in notification.Activities)
{
ApiNotificationActivity activityToAdd;
//First look at the parents
activityToAdd = activities.FirstOrDefault(a => a.Id == activity);
//Look in the children
if (activityToAdd == null)
{
activityToAdd = activities.SelectMany(x => x.Children)
.Where(x => x.Id == activity)
.FirstOrDefault();
}
if(activityToAdd != null)
{
_checkedValues.Append(activityToAdd);
}
}
FYI: The object notification.Activities is a list of guids. Running through the code gives me the approriate amount of values that needs to be checked in _checkedValues.