Hi Mattias,
Thanks for contacting Syncfusion support.
Yes, we have provided support to populate a menu from an asp.net web api. We can bind WebApi service’s data to Menu control by using the web api adaptor. Please refer the below link:
We have prepared the sample based on your requirement and it is available under the following link:
In the above sample, we have created the data in the web api controller method as shown below code:
<code>
public class ProductsController : ApiController
{
List<Product> products = new List<Product>()
{
new Product { Id = 1, Name = "Tomato Soup" },
new Product { Id = 2, Name = "Yo-yo"},
new Product { Id = 3, Name = "Hammer" },
new Product { Id= 4, Name = "Knife" },
new Product { Id= 4, Name = "Pen"},
};
public IEnumerable<Product> GetAllProducts()
{
return products;
}
}
</code>
Now, we can bind the data to the menu control in the script section as shown below code:
<code>
[HtmlPage1.html]
<div>
<h2>Menu</h2>
<ul id="menujson"></ul>
</div>
<script>
var dataManager = ej.DataManager({
url: "/api/products", //call the web api controller
adaptor: new ej.WebApiAdaptor()
});
$("#menujson").ejMenu({
fields: {
dataSource: dataManager,
id: "Id",
text: "Name",
}
});
</script>
</code>
To know more details about properties, methods and events of Menu component, please find the below API link:
Regards,
Kasithangam