イベントのrelatedTarget
プロパティを使用して、ユーザーがdatepickerコントロール内をクリックしたかどうかを検出できます。 datepickerの外側divはクラスui-datepicker
です。 focusout
がfocusoutに一度だけトリガされます。したがって、あなたのコードは
$(document).on('focusout','[role="gridcell"] *', function (e) {
var p = jqGridTegevused.jqGrid("getGridParam");
if ($(e.relatedTarget).closest('.ui-datepicker').length === 0) {
// save editing cell only if the current click is not inside of Datepicker
jqGridTegevused.jqGrid('saveCell', p.iRow, p.iCol);
}
});
次の問題として固定することができます。 0123,のdatepickerのコールバック内にコードを追加して、フォーカスを入力フィールドに強制的に設定して、後でユーザーがグリッドの外側をクリックできるようにする必要があります。* datepickerで日付を選択した後。
$(document).on('focusout','[role="gridcell"] *', ...);
の使用法が完全ではないことに感謝します。注意深くテストしてください。 afterEditCell
の入力/選択の中のfocusout
のバインドは、$(document).on('focusout','[role="gridcell"] *'
として私によく似ています。私は
afterEditCell: function (rowid, nm, tmp, iRow, iCol) {
var $grid = $(this);
$(this.rows[iRow].cells[iCol])
.find("input,textarea,select,button,object,*[tabindex]")
.filter(":input:visible:not(:disabled)")
.first()
.on("focusout", function (e) {
var p = $grid.jqGrid('getGridParam');
if ($(e.relatedTarget).closest('.ui-datepicker').length === 0) {
$grid.jqGrid('saveCell', p.iRow, p.iCol);
}
});
}
を使用し、私は日付ピッカーのonSelect
の内部入力要素にフォーカスを設定する追加ここhttps://jsfiddle.net/7oLga5ze/を参照。