2017-10-12 249 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(); 
%> 

*我想補充這是一個註釋這是一個不完整的答案,但是你不能添加代碼(或換行)來評論