2016-11-09 70 views
0

我有劍道子網格。它有一排。每行有一些單元格。如果我改變第一行以外的單元格的值,我必須獲得相應的第一行單元格值並進行一些驗證。見所附的圖像防止用戶單擊劍道網格中的其他單元

enter image description here

代碼

var $container = $(container), 
     tdIndex = $container.index(), 
     $correspondingCell = $container.closest("tbody").find("tr:first td:eq(" + tdIndex + ")"); 
      $('<input maxlength="9" data-bind="value:' + options.field + '"/>') 
       .appendTo($container) 
       .kendoNumericTextBox({ 
        format: "0.####", 
        decimals: 0, 
        min: 0, 
        spinners: false, 
        change: function (e) { 
         //debugger; 
         CalculateFormatWeeks(options.model); 
         var uid = options.model.uid; 
         var cellinx = $('#kenTitleFormatsGrid .k-edit-cell')[0].cellIndex; 
         var row = $("#kenTitleFormatsGrid tbody").find("[data-uid='" + uid + "']"); 
         var cell = row.children().eq(cellinx); 
         cell.css("font-style", "normal"); 
         console.log("From Cell", $correspondingCell.text()); 
         if (Number($correspondingCell.text()) == 0) { 
          alert("There is no daily GBO exists to enter the format gross. Please add the daily GBO data before proceeding"); 
         } 
        }       
       }).off("keydown"); 

回答

0

添加的處理程序網格的保存事件並在需要時使用grid.editCell()方法,即:

save: function (e) { 
    var $container = $(e.container), 
     tdIndex = $container.index(), 
     $correspondingCell = $container.closest("tbody").find("tr:first td:eq(" + tdIndex + ")"); 

    if (Number($correspondingCell.text()) == 0) { 
     alert("There is no daily GBO exists to enter the format gross. Please add the daily GBO data before proceeding"); 
     e.sender.editCell($container); 
    } 
    } 

演示:http://dojo.telerik.com/@Stephen/EDeFO

+0

我必須在單元格更改事件中編寫此條件,如果我爲保存事件寫入它,它會發射多次,因爲更改此單元格值我是aut omatically地改變星期和週末的列值,所以它更多次發射 – Gowthami

+0

然後添加一個針對e.values的檢查和一個if語句,以便只處理何時何地你想要的。 save事件觸發每個單元格,因此您必須添加邏輯以對所需的單元格執行適當的處​​理,並對您不關心的單元格執行任何操作。 –

0

試試吧 腳本級

function CloseEditable(e) {  
     this.closeCell();  

}

視圖級別

活動(事件=> events.Edit( 「CloseEditable」)

,如果你想關閉特定的細胞,然後讓細胞

的cellIndex
+0

我不認爲他只想編輯他點擊的單元格......他想讓編輯器留在他要離開的單元格上。 –

相關問題