Kendo UI MVC 调用 javascript 嵌套函数

Kendo UI MVC call javascript nested function

假设:

    @(Html.Kendo().Grid(Model)
       .Name("gridListCustomers")
       .Columns(gcf =>
       {
           gcf.Bound(c => c.Id).Hidden(true);
           gcf.Bound(c => c.Nom);
       })
       .Events(e => e.Change(???OnChange???)))

     <script>
       (function () {
          function OnChange (){
             //Todo
          }
       })();
     </script>

如何仅使用 MVC 模板定义来调用嵌套函数?

函数 OnChange 将仅在闭包范围内可用,这就是闭包的用途。

但是您可以使用 bind():

以另一种方式分配 change 事件
<script>
    $(function () {
        let grid = $('[name="gridListCustomers"]'); // Not sure if is this the right selector for your grid. Select the grid whatever way you like.

        grid.bind("change", function() {
            // Your chenge function body here
        }
    });
</script>