![](/img/trans.png)
[英].NET core MVC Kendo UI - How to write custom validation rule in kendo grid in inline edit mode
[英]how do i call the controller in kendo ui grid mvc
我如何在MVC Kendoui網格中調用控制器
這是代碼:
但不起作用:
.ClientTemplate(string.Format("<a class=\"modal\" rel=\"/address/#= Id #/map\" close=\"{0}\" title=\"{1}\"><img src=\"/content/images/ico_edit_16.png\" /></a>",
T("Common.Close").Text,
T("Address.MapAddress").Text)
這是控制器:
public ActionResult AddressMap( int accountId)
{
//load default accounts
var listModel = new AddressListModel();
//{
// AccountId = accountId,
// GridPageSize = _commonSettings.GridPageSize,
//};
//listModel.Addresses = new List<AddressModel>();
return View(listModel);
}
使用現有代碼:
.ClientTemplate(string.Format("<a class=\"modal\" rel=\"/address/#= Id #/map\"
close=\"{0}\" title=\"{1}\"><img src=\"/content/images/ico_edit_16.png\" /></a>",
T("Common.Close").Text,
T("Address.MapAddress").Text)
您將看到您正在設置a
標簽的相對設置,而不是href
屬性。
因此,您需要做的就是更改標簽,使其更像這樣:
(string.Format("<a class='k-link' href='{2}' close='{0}' title='{1}'><img src='/content/images/ico_edit_16.png' />#=Id#</a>",
T("Common.Close").Text,
T("Address.MapAddress").Text, @Url.Action("AddressMap", "{Your Controller}", new {accountId= "#=Id#"})))
我所要做的只是將URL傳遞給字符串格式化程序,然后將accountId
綁定到從dataItem傳遞到行中的ID。
我還向鏈接添加了ID,因此您可以看到正在顯示的內容。
如果這不是您想要的,請告訴我您的實際需求,我將相應地修改答案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.