ExtJSの使用4ユーザーが長い番号のリストを入力するためのグリッドを作成します。ユーザーが「Enter」を押して1つのセルの編集を終了し、自動的に下のセルに移動して編集を開始できるようにします。ExtJS 4:編集可能なグリッド内のExcelスタイルのキーボードナビゲーション
Ext.grid.plugin.CellEditingは編集の目的ではうまくいくようですが、keyUpイベントを検出して処理する方法が見つかりません。
私はこのコードで「編集」イベントを使用して問題に近づいてみました:
selType: 'cellmodel',
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
edit: function (editor, e, eOpts) {
// If the event is fired by pressing "Enter", the column and row associated with event will
// be the same as the currently selected row and column
if (e.grid.selModel.position.column == e.colIdx && e.grid.selModel.position.row == e.rowIdx){
// Check if we are in the final row
if (e.rowIdx+1 == e.grid.getStore().getTotalCount()){
return true;
}
editor.startEditByPosition({row: e.rowIdx+1, column: e.colIdx});
return false;
}
}
}
})
],
このアプローチの問題は、ユーザーがセルの編集を開始した場合、その後の外のGUI要素をクリックすることですグリッドでは、編集イベントはこれを「Enter」キーが押されているのと区別しません。これは修正できますか?
代わりにカスタムSelectionModelを実装する必要がありますか?どのようにそのアプローチから始めようとしていますか?
私は実際にそれを理解して、それと同じ解決策を考え出しました。それは動作します、ありがとう! JSFiddleがダウンするとコードを直接回答に追加しますか? – postrational