[英]Kendo UI Grid - ClientTemplate calling MVC Url.Action calls (incorrectly) two different actions
我猜,问题是什么导致“索引”操作被触发? 因为将显示该对话框,所以将填充详细数据,但是一旦关闭该对话框,所有过滤器文本框将被重置,网格将重新加载,其中的数据将被重新加载。
唯一的动作不应该是GetDetails吗?
任何提示将不胜感激!
码:
@(Html.Kendo().Grid<LogViewModel>()
.Name("LogGrid")
.Columns(column =>
{
column.Bound(x => x.StuffCount).Title("Stuff").Width(70)
.ClientTemplate("<a onclick=\"showAll('" + "#= Id #')\"" + " href=''>#= StuffCount #</a>");
})
.DataSource(dataBinding => dataBinding
.Ajax()
.PageSize(50)
.Read(read => read.Action("GetData", "Summary")
.Data("getSearchFilters"))
.Model(model => model.Id(o => o.Id)))
.Events(e => e
.DataBound("onGridItemsDatabound"))
.Pageable(paging => paging.Refresh(true))
)}
<div id="dialog-message" title="" style="display: none">
<p id="msg"></p>
</div>
<script type="text/javascript">
var showAll= function (id) {
var url = '@Url.Action("GetDetails", "Summary")' + "/" + id;
var sTitle = 'title text';
$.getJSON(url, null,
function (data) {
$("#dialog-message").dialog({ title: sTitle });
$("#msg").text(data.details);
showMessage();
});
};
var showMessage = function () {
$("#dialog-message").dialog({
modal: true,
draggable: false,
resizable: false,
buttons: {
Ok: function() {
$(this).dialog("close");
}
}
});
};
</script>
控制器方法(为简洁起见,删除了内容
public ActionResult Index(...)
{
...
}
public ActionResult GetDetails(Guid id)
{
... (get data from repository)
return Json(data, JsonRequestBehavior.AllowGet);
}
我在Telerik论坛上发布了相同的问题。 他们的管理员为我指明了正确的方向:
原来,我不得不在href中添加空格以调用javascript并停留在页面上。 href =“ javascript:void(0)”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.