我有劍道子網格。它有一排。每行有一些單元格。如果我改變第一行以外的單元格的值,我必須獲得相應的第一行單元格值並進行一些驗證。見所附的圖像防止用戶單擊劍道網格中的其他單元
代碼
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");
我必須在單元格更改事件中編寫此條件,如果我爲保存事件寫入它,它會發射多次,因爲更改此單元格值我是aut omatically地改變星期和週末的列值,所以它更多次發射 – Gowthami
然後添加一個針對e.values的檢查和一個if語句,以便只處理何時何地你想要的。 save事件觸發每個單元格,因此您必須添加邏輯以對所需的單元格執行適當的處理,並對您不關心的單元格執行任何操作。 –