My document ready function is in .js file not in cshtml file. I can find the instance of the grid in document ready function if i move the .js file at the end of the .cshtml file. So that issue is resolved now.
Question
Can i attach dataBound event through .cshtml as below. If i do this i get error on view load.
0x800a1391 - JavaScript runtime error: 'onDataBound' is undefined
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<
div
>
@(Html.Kendo().Grid<
MVCPOC.Models.AssessorAccounts
>()
.Name("Grid")
.Columns(col =>
{
col.Bound(p => p.AssessorName).Title("AssessorName");
col.Bound(p => p.Taxyear).Title("Year");
})
.AutoBind(true)
.Pageable()
.Sortable()
.Events(x => x.DataBound("onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read
.Action("GetData", "Working")))
)
</
div
>
<
script
src
=
"~/Scripts/Working.js"
></
script
>
The document ready function below is in separate .js file
$(function () {
function onDataBound() {
// grid could not find this function
}
})