【问题标题】:Call knockout method inside kendo grid在剑道网格内调用剔除方法
【发布时间】:2018-08-26 17:55:55
【问题描述】:

我有简单的剑道 UI 网格

$("#Grid").kendoGrid({
    dataSource: {
        serverPaging: true,
        transport: {
            read: "Course/Read",
            dataType: "json"
        },
        schema: {
            data: "Data",
            total: "Total",
            errors: "Errors"
        },
        pageSize: 10
    },
    pageable: true,
    columns:
        [
          { field: "CourseName", title: "Name", width: 100 },
          { field: "SpecialtyName", title: "Specialty", width: 100, filterable: false },
          { title: "Edit", template: '<span class="EditIcon"><i data-bind="click:Edit(#: Id#)" class="fa fa-edit"></i></span>', width: 50 },
        ]
});

问题出在我使用的时候:

 data-bind="click:Edit(#: Id#)"

当点击编辑调用函数在剑道网格内不起作用时,请注意网格和函数在淘汰视图模型内

function viewmodel() {
    var self = this;
 self.Load = function () {
$("#Grid").kendoGrid({
    dataSource: {
        type: "aspnetmvc-ajax",
        serverPaging: true,
        transport: {
            read: "Course/Read",
            dataType: "json"
        },
        schema: {
            data: "Data",
            total: "Total",
            errors: "Errors"
        },
        pageSize: 10
    },
    pageable: true,
    columns:
        [
          { field: "CourseName", title: "Name", width: 100 },
          { field: "SpecialtyName", title: "Specialty", width: 100, filterable: false },
          { title: "Edit", template: '<span class="EditIcon"><i data-bind="click:Edit(#: Id#)" class="fa fa-edit"></i></span>', width: 50 },
        ]
});
}
self.Load();
self.Edit= function (Id) {
////////my code////////
}
}

绑定检索数据一切正常,除了在剑道网格内调用敲除方法外,感谢任何帮助。

【问题讨论】:

    标签: asp.net-mvc knockout.js kendo-ui kendo-asp.net-mvc knockout-mvc


    【解决方案1】:

    如果有人在寻找答案或打开此帖子,这与剑道无关,这是因为网格在敲除绑定完成后呈现行,因此您可以在 javascript 中的 temp var 中获取 viewmodel 对象并像 tempvar.callfunction 一样使用它()。

    【讨论】:

      猜你喜欢
      • 2016-12-18
      • 2020-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      相关资源
      最近更新 更多