同じように構築された別のコントロールがあるので、何かが足りないに違いありませんが、この問題はありません。.NETのregisterClientScriptIncludeを介して登録されたjQueryグリッドコントロールがあります。両方のグリッドですべてが正常に機能していますが、Datatables KeyTableライブラリから関数を呼び出しています。この関数は、ユーザーがグリッドをキー入力してテーブル行の最後に到達したときにページを強制的に変更し、次のページに移動します。
これらのコントロールを登録すると、次のようになります。
var lookupGrid = registerGrid('pageContent_tbl1',...)
var lookupGrid2 = registerGrid('pageContent_tbl2',...)
グリッドのコードは、埋め込みリソースであるJSファイルにあります。
var registerGrid = function (table, ...) {
grid = {
"oTable": $("#" + table).dataTable({
"bProcessing": true,
...
}),
"focusPostDraw": function (position) {
var drawCB = function () {
if (position === 'top') {
keys.fnSetPosition($('#' + table + " tbody tr:first td.canEdit:first ")[0].cellIndex, 0);
keys.fnRemoveFocus($('#' + table + " tbody tr:last td.canEdit:last "));
} else if (position === 'bottom') {
var oSettings = inlineGrid.oTable.fnSettings();
keys.fnSetPosition($('#' + table + " tbody tr:last td.canEdit:last ")[0].cellIndex, oSettings._iDisplayLength - 1);
keys.fnRemoveFocus($('#' + table + " tbody tr:first td.canEdit:first "));
} else {
// Do Nothing
}
grid.setInlineGridHandler(function () { });
};
grid.setInlineGridHandler(drawCB);
}
};
return grid;
}
focusPostDrawを呼び出すとすべてが見栄えがしますが、次のように呼び出すと次のようになります。
grid.setInlineGridHandler(drawCB);
グリッド変数は、実際には、lookupGridではなく、グリッドのlookupGrid2インスタンスを指しています。不思議なことに、テーブル変数はlookupGridのテーブル変数のIDに設定されています。何が起こっている?誰か考えがありますか?