2017-10-12 147 views
1

剑道电网BeforeEdit事件的文件清楚地显示在网格中BeforeEdit事件:犯规存在

但是有什么版本的没有提及这个应运而生的。我们正在使用版本2016.3.914。我得到一个错误,说它不存在(我尝试在MVC代码和jQuery中使用)。

function onDataBound(gridName) { 
    return function (e) { 
     var grid = $("#" + gridName).data("kendoGrid"); 
     species = extractSpecies(gridName); 
     $("#Species").val(species); 
     $("#" + gridName).data("kendoGrid").beforeEdit((e2) => { 
      console.log("before edit"); 
     }); 
     console.log('WATCH01 NoiNLSConsignment/onDataBinding() - species is: ', species); 
    } 
} 

OpenNlsApplication?exporterId=6190&applicationId=6191:2457 

Uncaught TypeError: $(...).data(...).beforeEdit is not a function(…) 
    (anonymous function) @ OpenNlsApplication?exporterId=6190&applicationId=6191:2457 
    trigger     @ kendo.all.min.js:25 
    refresh     @ kendo.all.min.js:51 
    d      @ jquery.min.js:2 
    trigger     @ kendo.all.min.js:25 
    _process    @ kendo.all.min.js:28 
    success     @ kendo.all.min.js:27 
    success     @ kendo.all.min.js:27 
    n.success    @ kendo.all.min.js:27 
    i      @ jquery.min.js:2 
    fireWith    @ jquery.min.js:2 
    y      @ jquery.min.js:4 
    c      @ jquery.min.js:4 

第一个问题是你怎么知道什么版本在剑道增加了一些功能?

其次是,我无法控制所使用的版本。有没有一种方法可以在编辑之前进入生命周期?即。 event.Edit()为时已晚。

回答

0

我对我的第二个问题*有一个答案。

我发现我只需要“BeforeEdit”时editing(而不是当creating),所以它是很容易被一些jQuery的添加到编辑按钮:

function onDataBound(gridName) { 
    return function (e) { 
     // This part is for when create a new Species/Animal Type 
     species = extractSpecies(gridName); 
     $("#Species").val(species); 

     // This next part is for when edit 
     // It would have been preferable to use the beforeEdit event, however that doesn't seem to exist in the version of 
     // MVC Kendo that is being used currently (2016.3.914) 
     $("div#" + gridName + " a[title*='edit this Animal']").on('click', function() { 
      var localSpecies = extractSpecies(gridName); 
      $("#Species").val(localSpecies); 
      species = localSpecies; // Set the global 
     }); 
    } 
} 

而且在电网的定义:

<% 
    Html.Kendo().Grid<NoiNlsConsignmentVO>() 
        .Name(gridNameID) 
        ... 
        .Events(events => { 
         events.Edit("onEditLivestockClicked(\"" + gridNameID + "\")"); 
         events.DataBound("onDataBound(\"" + gridNameID + "\")"); 
         events.Save("onLivestockSave(\"" + gridNameID + "\")"); 
        }) 
        .Sortable() 
        .Render(); 
%> 

*我想补充这是一个注释这是一个不完整的答案,但是你不能添加代码(或换行)来评论