Adding Menu Item with self-referential data

Is it possible to use self-referential data to modify menu items? In the example below, using Text and Children field settings I can get it to work but not if I use ItemId, Text, ParentId field settings.

<SfButton @onclick="Update">Update</SfButton>

<br />

<div>Menu A: using Text and Children fields</div>

<SfMenu Items="@MenuItems" @ref="MenuObj">

    <MenuFieldSettings Text="@nameof(DataList.Data)" Children="@nameof(DataList.SubDatas)"></MenuFieldSettings>

</SfMenu>

<br />

<div>Menu B: using self-referential data (Id, Text, ParentId fields)</div>

<SfMenu Items="@MenuItems1" @ref="MenuObj1">

    <MenuFieldSettings ItemId="Id" Text="Text" ParentId="ParentId"></MenuFieldSettings>

</SfMenu>


@code {

    SfMenu<DataList> MenuObj;

    SfMenu<DataList1> MenuObj1;


    public List<DataList> MenuItems = new List<DataList>

    {

        new DataList

        {

            Data = "Company", SubDatas = new List<DataList>

            {

            new DataList{ Data= "Overview" }

            }

        }

    };


    public List<DataList1> MenuItems1 = new List<DataList1>

    {

        new DataList1{ Id = "parent1", Text = "Company" },

        new DataList1{ Id = "parent2", Text = "Company", ParentId = "parent1" }

    };


    public class DataList

    {

        public string Data { get; set; }

        public List<DataList> SubDatas { get; set; }

    }


    public class DataList1

    {

        public string Id { get; set; }

        public string Text { get; set; }

        public string ParentId { get; set; }

    }


    public void Update()

    {

        MenuObj1.Items.Add(new DataList1 {Id = "parent5", Text = "Services" });

        MenuObj1.Items.Add(new DataList1 {Id = "parent6", Text = "Consulting", ParentId = "parent5" });


        MenuObj.Items.Add(new DataList { Data = "Services", SubDatas = new List<DataList> {new DataList{ Data = "Consulting"}, } });

    }

}


3 Replies

JS Janakiraman Sakthivel Syncfusion Team February 15, 2022 02:38 AM UTC

Hi Dave, 
 
Thank you for contacting Syncfusion support. 
 
We need to validate more on the reported query, so will update you the further details on February 16th, 2022. 
 
Regards, 
Janakiraman S. 



JS Janakiraman Sakthivel Syncfusion Team February 18, 2022 03:53 AM UTC

Hi Dave, 
  
We are able to replicate your reported issues in our end. And we have logged this as a bug and this fix will be available in our March 9th patch release. We appreciate your patience until then. 
  
You can also track the status of this bug by using below feedback portal link.    
   
 
Please let us know if you have any queries. 
 
Regards, 
Janakiraman S. 



SP Sangeetha Priya Murugan Syncfusion Team March 10, 2022 11:47 AM UTC

Hi Dave, 
 
We are glad to announce that our weekly patch release (19.4.55) is rolled out. We have included the fix for the reported defect in this release. So, we suggest you upgrade our Syncfusion Spreadsheet package to our latest version to resolve this issue in your end.   
 
 
 
Regards, 
Sangeetha M 


Loader.
Up arrow icon