Tree Component not returning expected results

The issue I am running into has to do with when the children nodes are displayed. I am running v4.7.11.

A view of the tree

image

Scenario 1 - Select parent node and do not expand the list.

Result: This returns the correct results.

[
  {
    "PropertyName": "Parent",
    "ChildProperties": [
      {
        "PropertyName": "Child-1",
        "ChildProperties": []
      },
      {
        "PropertyName": "Child-2",
        "ChildProperties": []
      },
      {
        "PropertyName": "Child-3",
        "ChildProperties": []
      }
    ]
  }
]

Scenario 2 - Expand Parent row (use carrot) then click Parent checkbox to select each child.

Result: This does not return the correct results. Since the children nodes are now visible, they get included twice in the results.

As you can see in the results, the Parent node is returned with the correct children. However, each child is also returned.

[
  {
    "PropertyName": "Parent",
    "ChildProperties": [
      {
        "PropertyName": "Child-1",
        "ChildProperties": []
      },
      {
        "PropertyName": "Child-2",
        "ChildProperties": []
      },
      {
        "PropertyName": "Child-3",
        "ChildProperties": []
      }
    ]
  },
  {
    "PropertyName": "Child-1",
    "ChildProperties": []
  },
  {
    "PropertyName": "Child-2",
    "ChildProperties": []
  },
  {
    "PropertyName": "Child-3",
    "ChildProperties": []
  }
]

The tree component is defined like:

 <RadzenTree AllowCheckBoxes="true" @bind-CheckedValues=@CheckedValues Data=@properties Style="min-height: 300px">
            <RadzenTreeLevel TextProperty="PropertyName" ChildrenProperty="ChildProperties"
                             HasChildren=@(e => (e as ClassProperty).ChildProperties.Any()) />
        </RadzenTree>


@code {

IEnumerable<object> CheckedValues
    {
        get => checkedValues;
        set
        {
            checkedValues = value;
            if (checkedValues != null)
            {
                string jsonCheckedValues = Newtonsoft.Json.JsonConvert.SerializeObject(checkedValues);
                InputText = jsonCheckedValues;
            }
        }
    }
	
}

The class used to populate the tree control.

public class ClassProperty
    {
        public string PropertyName { get; set; }
        public List<ClassProperty> ChildProperties { get; set; } = new List<ClassProperty>();
    }

Is the Tree control working as expected?

Thanks.

Steve

Hi, I also faced with this issue in last 3 days, and investigated but didn't get any solution. Now I've intended to ask question in here but realized that you already asked. By the way this Radzen.Tree works correctly in Radzen's official site.

@sromankiw I've found solution in other question related with this issue. Just update Radzen package version to the last stable so problem has been fixed.

@Ali_Alizade I downloaded the latest version from NuGet (v4.7.12). My original issue still exists in this version.

Whenever the children nodes are displayed, the results are not correct.

Radzen Support, any insight?

Hey @sromankiw,

I would like to kindly remind that our support is guaranteed for subscribers only. If you are looking for paid support check our pricing page for reference.

Hey @enchev ,

As @sromankiw mentioned before, there is a discrepancy between Parent and Child nodes. So, if child node is expanded and you checking all elements of expanded child node then it must be checked parent node automatically and should be keep only parent node into the selected items, not both parent node and child node together.

Best regards,
Ali

1 Like