Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is `data("kendoGrid")` undefined?
    primarykey
    data
    text
    <p>I have two Kendo grid definitions, in partial views, that are exactly the same save for the partial view model and the grid item model. Only one of then gives me the JavaScript console error 'Cannot read property 'dataSource' of undefined' on the line of code:</p> <pre><code>$("#index-grid").data("kendoGrid").dataSource.bind("change", function (e) {...}) </code></pre> <p>and the other does not. It is not <code>dataSource</code> that is undefined, but <code>$("#index-grid").data("kendoGrid")</code>. Yet, in the other identical grid, I do not get this error. Can the data provided to the data source perhaps invalidate the grid itself? The grid definitions look like this:</p> <pre><code>@model TerminalIndexModel @using Kendo.Mvc.UI @using ParkPay.Helm.ViewModels @(Html.Kendo().Grid&lt;TerminalIndexItem&gt;() .Name("index-grid") .Columns(columns =&gt; { columns.Bound(p =&gt; p.Name); columns.Template(@&lt;text&gt;&lt;/text&gt;).ClientTemplate("&lt;input type='checkbox' #= IsActive ? checked='checked':'' # class='chkbx' /&gt;").Title("Active").Width(70); columns.Bound(p =&gt; p.Remarks); columns.Command(cmd =&gt; cmd.Destroy()).Width(80); }) .ToolBar(toolbar =&gt; { toolbar.Create(); toolbar.Save(); }) .HtmlAttributes(new { style = "height: 480px;"}) .Editable(editable =&gt; editable.Mode(GridEditMode.InCell)) .Filterable() .Pageable() .Scrollable() .Sortable() .Resizable(resize =&gt; resize.Columns(true)) .Reorderable(reorder =&gt; reorder.Columns(true)) .DataSource(dataSource =&gt; dataSource .Ajax() .ServerOperation(false) .Batch(true) .PageSize(20) .Events(events =&gt; events.Error("kendoGridErrorHandler")) .Model(model =&gt; model.Id(p =&gt; p.Id)) .Read(read =&gt; read.Action("Read", "Terminal")) .Update(update =&gt; update.Action("BatchUpdate", "Terminal")) .Create(create =&gt; create.Action("BatchCreate", "Terminal")) .Destroy(destroy =&gt; destroy.Action("BatchDelete", "Terminal")) ) ) </code></pre> <p>with the only difference being <code>TerminalIndexItem</code> versus <code>LocationIndexItem' and and</code>TerminalIndexModel<code>versus</code>LocationIndexModel<code>, and of course the controller names in the CRUD definitions,</code>Terminal<code>versus</code>Location`. I am at my wit's end finding a difference between the two grids.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload