I am using MVC Kendo UI. I have defined my grid in Razor
@(Html.Kendo().Grid<BatchDetails>() .Name("Grid") .Columns(col => { col.Bound(p => p.BatchDetailID) .ClientTemplate("<input class='chkbox' type='checkbox' value='#=BatchDetailID#' />") .HeaderTemplate("<input type='checkbox' id='selectAll' />") .Width(30) .Sortable(false) .Filterable(false); col.Bound(p => p.BatchKey).Title("State"); col.Bound(p => p.OriginalCost).Title("Total Cost"); }) .AutoBind(true) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Read(read => read .Action("GetData", "Home", new { batchID = Model.BatchID }))))
1> I want to bind DataBound event of the grid in document ready function.
but when i do that i get null reference.
$function({ var grid = $("#Grid").data("kendoGrid"); // grid variable is null here grid.bind("dataBound", function(){ //dosomething here }); })2>If i bind the event using the following approach then i have to declare the onDataGridBound function as Global. The Grid cannot access scoped function
@(Html.Kendo().Grid<BatchDetails>() .Name("Grid") .Events(x => x.DataBound("onDataGridBound")) ) is there any way to declare onDataGridBound as scoped function, and grid can still access it?