gpt4 book ai didi

telerik - 为什么 `data("kendoGrid")` 未定义?

转载 作者:行者123 更新时间:2023-12-01 02:25:09 25 4
gpt4 key购买 nike

我有两个 Kendo 网格定义,在局部 View 中,除了局部 View 模型和网格项模型之外,它们完全相同。只有其中一个给了我 JavaScript 控制台错误 'Cannot read property 'dataSource' of undefined' 在代码行上:

$("#index-grid").data("kendoGrid").dataSource.bind("change", function (e) {...})

而另一个没有。不是 dataSource这是未定义的,但是 $("#index-grid").data("kendoGrid") .然而,在另一个相同的网格中,我没有收到此错误。提供给数据源的数据可能会使网格本身无效吗?网格定义如下所示:
@model TerminalIndexModel
@using Kendo.Mvc.UI
@using ParkPay.Helm.ViewModels
@(Html.Kendo().Grid<TerminalIndexItem>()
.Name("index-grid")
.Columns(columns =>
{
columns.Bound(p => p.Name);
columns.Template(@<text></text>).ClientTemplate("<input type='checkbox' #= IsActive ? checked='checked':'' # class='chkbx' />").Title("Active").Width(70);
columns.Bound(p => p.Remarks);
columns.Command(cmd => cmd.Destroy()).Width(80);
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.HtmlAttributes(new { style = "height: 480px;"})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Filterable()
.Pageable()
.Scrollable()
.Sortable()
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Batch(true)
.PageSize(20)
.Events(events => events.Error("kendoGridErrorHandler"))
.Model(model => model.Id(p => p.Id))
.Read(read => read.Action("Read", "Terminal"))
.Update(update => update.Action("BatchUpdate", "Terminal"))
.Create(create => create.Action("BatchCreate", "Terminal"))
.Destroy(destroy => destroy.Action("BatchDelete", "Terminal"))
)
)

唯一的区别是 TerminalIndexItemLocationIndexItem' and and TerminalIndexModel versus LocationIndexModel , and of course the controller names in the CRUD definitions,终端 versus位置`。我终于找到了两个网格之间的差异。

最佳答案

两个网格的显示时间与问题行的执行时间有什么区别吗?意思是,对于有效的网格,是否有可能在该行执行时已经初始化,而对于有问题的网格则没有?

关于telerik - 为什么 `data("kendoGrid")` 未定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17071758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com