I have the following partial view:
@model StudentUnion0105.Controllers.PartialController
<div class="menu-control"><ejs-menu id="menuInTop" items="ViewBag.menuItems2"></ejs-menu></div>
The following script in the _Layout:
$("#TopMenu").load("/Partial/TopMenu");
and the following div in the _Layout:
<div id="TopMenu"></div>
The controller for the partial view is:
public async Task<IActionResult> TopMenu()
{
var CurrentUser = await userManager.GetUserAsync(User);
var DefaultLanguageID = CurrentUser.DefaultLanguageId;
var parameter = new SqlParameter("@LanguageId", DefaultLanguageID);
var TopMenu1List = _context.ZdbTopMenu1.FromSql("PartialTopMenu1 @LanguageId", parameter).ToList();
List<MenuItem> menuItem1List = new List<MenuItem>();
foreach (var TopMenu1 in TopMenu1List)
{
menuItem1List.Add(new MenuItem
{
Text = TopMenu1.MenuName,
IconCss = TopMenu1.IconCss,
Url = TopMenu1.MenuController,
Items = new List<MenuItem>()
{
new MenuItem { Text= "Open", IconCss= "em-icons e-open", Url= "Home/Open" },
new MenuItem { Text= "Save", IconCss= "e-icons e-save", Url= "Home/Save" },
new MenuItem { Separator= true },
new MenuItem { Text= "Exit", Url= "Home/Exit" }
}
});
Including:
using Syncfusion.EJ2.Navigations;
First level of the menu is coming from the database, second level for testing is hardcoded.
Further, when I debug on the partial view:
ViewBag.menuItems2 = menuItem1List;
return PartialView();
I see that the viewbag will have values. See image attached.
I did all kind of scenarios Some getting more results than others but no menu. (some had the div tag from the partial view.). At one time I had a UL tag but no IL.
Any suggestions what to do?
Thanks,
Peter
Attachment:
ViewBag_d9ff57b9.zip