This question is locked. New answers and comments are not allowed.
I would like to override the ActionLink default menu item. I've tried the following code (and would actually like to use the commented out part) to no avail.
I got past duplicate variable compile errors (there is another menu in the master page) by changing the linq variable names.
Now I get nothing displayed at all. All of the examples I have seen manually add the menu items to the menu, none of the examples have the ItemDataBound.
Please help me understand what I am doing wrong. Thanks
@(Html.Telerik().Menu()
.Name("Menu")
.BindTo(Model.MenuItems, mappings =>
{
mappings.For<ExplorerToolbarDataViewModel>(binding => binding
.ItemDataBound((explorerItem, explorerMenuItem) =>
{
explorerItem.Content = () =>
{
MvcHtmlString.Create(string.Format("<input type='image' src="~/Content/images/toolbar-placeholder.gif" value='{0}' id='{1}' class='{2}' onclick=\"$('#{3}').val('{4}')\" />",
explorerMenuItem.Name,
explorerMenuItem.Id,
explorerMenuItem.LinkHtmlAttributes.FirstOrDefault(a => a.Key == "class"),
explorerMenuItem.UpdateTargetId,
explorerMenuItem.Command));
};
}));
}))
@*<input type='image' value='@explorerMenuItem.Name' id='@explorerMenuItem.Id' class='@explorerMenuItem.LinkHtmlAttributes.FirstOrDefault(a => a.Key == "class")' onclick="$('#@explorerMenuItem.UpdateTargetId').val('@explorerMenuItem.Command')" />*@
@Html.HiddenFor(m => m.Command, new { id = "cmc_explorer_toolbar_command" })
@Html.HiddenFor(m => m.ExplorerPath, new { id = "cmc_explorer_toolbar_path" })
@Html.HiddenFor(m => m.ExplorerType, new { id = "cmc_explorer_toolbar_type" })
public class ExplorerToolbarViewModel : ToolbarViewModel
{
public ExplorerToolbarViewModel()
{
this.MenuItems = new Collection<ExplorerToolbarDataViewModel>();
}
public new Collection<ExplorerToolbarDataViewModel> MenuItems { get; set; }
public string ExplorerPath { get; set; }
public string Command { get; set; }
public ExplorerObjectType ExplorerType { get; set; }
}