单击 MVC5 中的 kendo 上下文菜单调用视图
Calling a view on click of the kendo context menu in MVC5
我已经在我的 MVC 5 页面上实现了 kendo 上下文菜单和网格。我需要通过将 requestid 传递给它来在点击编辑时导航到另一个页面。当我尝试调用 @{Html.RenderAction("NewRequest_Read", "Request");} 它会预先加载视图以及包含上下文菜单的视图。有人能告诉我该怎么做吗
上下文菜单
@(Html.Kendo().ContextMenu()
.Name("RequestMenu")
.Target("#GridRequest")
.Filter("tr")
.Orientation(ContextMenuOrientation.Vertical)
.Animation(animation =>
{
animation.Open(open =>
{
open.Fade(FadeDirection.In);
open.Duration(500);
});
})
.Items(items =>
{
items.Add()
.Text("Edit");
items.Add()
.Text("Cancel");
})
.Events(e =>
{
e.Select("onSelect");
})
)
脚本
function onSelect(e) {
var grid = $("#GridTeam").data("kendoGrid");
switch ($(e.item).children(".k-link").text()) {
case "Edit":
@{Html.RenderAction("NewRequest_Read", "Request");}
break;
case "Cancel":
grid.removeRow(e.target);
break;
}
}
控制器方法
public ActionResult NewRequest_Read(string id)
{
NewRequestViewModel newReqeustViewModel = new NewRequestViewModel();
return View("NewRequestView", newReqeustViewModel);
}
function onSelect(e) {
var grid = $("#GridTeam").data("kendoGrid");
switch ($(e.item).children(".k-link").text()) {
case "Edit":
window.location.href = '@Url.Action("NewRequest_Read", "Request", new { id = //add request id parameter here })';
break;
case "Cancel":
grid.removeRow(e.target);
break;
}
}
我已经在我的 MVC 5 页面上实现了 kendo 上下文菜单和网格。我需要通过将 requestid 传递给它来在点击编辑时导航到另一个页面。当我尝试调用 @{Html.RenderAction("NewRequest_Read", "Request");} 它会预先加载视图以及包含上下文菜单的视图。有人能告诉我该怎么做吗
上下文菜单
@(Html.Kendo().ContextMenu()
.Name("RequestMenu")
.Target("#GridRequest")
.Filter("tr")
.Orientation(ContextMenuOrientation.Vertical)
.Animation(animation =>
{
animation.Open(open =>
{
open.Fade(FadeDirection.In);
open.Duration(500);
});
})
.Items(items =>
{
items.Add()
.Text("Edit");
items.Add()
.Text("Cancel");
})
.Events(e =>
{
e.Select("onSelect");
})
)
脚本
function onSelect(e) {
var grid = $("#GridTeam").data("kendoGrid");
switch ($(e.item).children(".k-link").text()) {
case "Edit":
@{Html.RenderAction("NewRequest_Read", "Request");}
break;
case "Cancel":
grid.removeRow(e.target);
break;
}
}
控制器方法
public ActionResult NewRequest_Read(string id)
{
NewRequestViewModel newReqeustViewModel = new NewRequestViewModel();
return View("NewRequestView", newReqeustViewModel);
}
function onSelect(e) {
var grid = $("#GridTeam").data("kendoGrid");
switch ($(e.item).children(".k-link").text()) {
case "Edit":
window.location.href = '@Url.Action("NewRequest_Read", "Request", new { id = //add request id parameter here })';
break;
case "Cancel":
grid.removeRow(e.target);
break;
}
}