Sitemap for Menu Bar

When will the menubar support loading from a sitemap? I have a comprehensive menu map from another application and it would be nice to re-use most of it.

TIA,

Miles

1 Reply 1 reply marked as answer

GK Gayathri KarunaiAnandam Syncfusion Team February 2, 2021 09:31 AM UTC

Hi Miles, 

Thank you for contacting Syncfusion Support. 

We have checked your reported query and we have loaded Menubar component from sitemap using XML as demonstrated in the below code snippet 
Index.razor 
 
<SfMenu Items="MainItems" TValue="Report"> 
    <MenuFieldSettings Text="Name" Children="Reports" ItemId="Id"></MenuFieldSettings> 
</SfMenu> 
 
@code { 
 
    private List<Report> MainItems { get; set; } 
    protected override Task OnInitializedAsync() 
    { 
        XmlSerializer serializer = new XmlSerializer(typeof(ReportData), new XmlRootAttribute("root")); 
        StreamReader file = new StreamReader(Startup._env.WebRootPath.ToString() + "/Nav.xml"); 
        ReportData reportData = (ReportData)serializer.Deserialize(file); 
        MainItems = reportData.Reports; 
        return base.OnInitializedAsync(); 
    } 
 
 
 
    // Model for shared XML 
    public class ReportData 
    { 
        [XmlElement("element")] 
        public List<Report> Reports { get; set; } = null; 
    } 
 
    public class Report 
    { 
        [XmlElement("ID")] 
        public string Id { get; set; } 
 
        public bool IsVisible { get; set; } 
 
        public string ItemCssClass { get; set; } 
 
        public string Name { get; set; } 
 
        public int SubID { get; set; } 
 
        public int Type { get; set; } 
 
        [XmlElement("element")] 
        public List<Report> Reports { get; set; } = null; 
    } 
} 

For your reference, we have prepared a sample based on your requirement. Please check the below link 


Please check the above sample and get back to us if you need further assistance.  

Regards, 
Gayathri K 


Marked as answer
Loader.
Up arrow icon