【发布时间】:2013-08-11 12:09:11
【问题描述】:
我是 kendo.Ui 的初学者,我编写此代码用于创建网格
@(Html.Kendo().Grid<BrandViewModel>(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.BrandName);
columns.Bound(p => p.BrandAbbr);
columns.Bound(p => p.SrcImage);
columns.Command(command => command.Custom("Edit").Click("editItem"));
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("CustomCommand_Read", "Brand"))
.Model(model => model.Id(p => p.Id))
)
)
我想当用户点击 Edit 按钮时在剑道窗口中打开 Edit view 我写这段代码
@(Html.Kendo().Window().Name("Details")
.Title("Customer Details")
.Visible(false)
.Modal(true)
.Draggable(true)
.Width(300)
)
<script type="text/x-kendo-template" id="template">
<div id="details-container"> <!-- this will be the content of the popup -->
BrandName: <input type='text' value='#= BrandName #' />
</div>
</script>
和java脚本代码:
<script type="text/javascript">
var detailsTemplate = kendo.template($("#template").html());
function editItem(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
$("#Details").data("kendoWindow").refresh({
url: "/Brand/Edit/" + dataItem.Id
});
$("#Details").data("kendoWindow").open();
}
</script>
这段代码工作正常我第一次点击一个按钮,但是当我第二次点击时,我遇到了以下错误
0x800a138f - JavaScript runtime error: Unable to get property 'refresh' of undefined or null reference
请帮帮我,谢谢大家
【问题讨论】:
-
从你的问题中学到了一些与你的问题无关的新东西:)
标签: asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc