Skip to content

Commit f0fa0bd

Browse files
authored
fix: add autoEditNewRow option to disable auto-edit new row, fix #445 (#855)
- fixes #445 - when using CellExternalCopyManager and user wants to paste cell selection range, it could be useful to not automatically open the cell that was clicked even if it has an editor defined
1 parent f4956e4 commit f0fa0bd

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

examples/example-excel-compatible-spreadsheet.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ <h2>View Source:</h2>
113113
enableAddRow: true,
114114
enableCellNavigation: true,
115115
asyncEditorLoading: false,
116-
autoEdit: false
116+
autoEdit: false,
117+
autoEditNewRow: false
117118
};
118119

119120
var undoRedoBuffer = {

src/models/gridOption.interface.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,21 @@ export interface GridOption<C extends BaseColumn = BaseColumn> {
4343
// TODO: not sure what that option does?
4444
auto?: boolean;
4545

46-
/** Defaults to false, when enabled will try to commit the current edit without focusing on the next row. If a custom editor is implemented and the grid cannot auto commit, you must use this option to implement it yourself */
46+
/**
47+
* Defaults to false, when enabled will try to commit the current edit without focusing on the next row.
48+
* If a custom editor is implemented and the grid cannot auto commit, you must use this option to implement it yourself
49+
*/
4750
autoCommitEdit?: boolean;
4851

49-
/** Defaults to false, when enabled will automatically open the inlined editor as soon as there is a focus on the cell (can be combined with "enableCellNavigation: true"). */
52+
/** Defaults to false, when enabled it will automatically open the inlined editor as soon as there is a focus on the cell (can be combined with "enableCellNavigation: true"). */
5053
autoEdit?: boolean;
5154

55+
/**
56+
* Defaults to true, when enabled it will automatically open the editor when clicking on cell that has a defined editor.
57+
* When using CellExternalCopyManager, this option could be useful to avoid opening the cell editor automatically on empty new row and we wish to paste our cell selection range.
58+
*/
59+
autoEditNewRow?: boolean;
60+
5261
/** Defaults to false, which leads to automatically adjust the size (height) of the grid to display the entire content without any scrolling in the grid. */
5362
autoHeight?: boolean;
5463

src/slick.grid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
213213
leaveSpaceForNewRows: false,
214214
editable: false,
215215
autoEdit: true,
216+
autoEditNewRow: true,
216217
autoCommitEdit: false,
217218
suppressActiveCellChangeOnEdit: false,
218219
enableCellNavigation: true,
@@ -5560,7 +5561,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
55605561
this.activeRow = cell.row;
55615562
this.activeCell = this.activePosX = this.activeCell = this.activePosX = this.getCellFromNode(this.activeCellNode);
55625563

5563-
if (opt_editMode == null) {
5564+
if (opt_editMode == null && this._options.autoEditNewRow) {
55645565
opt_editMode = (this.activeRow == this.getDataLength()) || this._options.autoEdit;
55655566
}
55665567

0 commit comments

Comments
 (0)