Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to disable automatic cursor advance after making an inline edit #2028

Merged
merged 1 commit into from
May 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions src/w2grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class w2grid extends w2event {
this.method = null // if defined, then overwrites ajax method
this.dataType = null // if defined, then overwrites w2utils.settings.dataType
this.parser = null
this.advanceOnEdit = true // automatically begin editing the next cell after submitting an inline edit?

// these column properties will be saved in stateSave()
this.stateColProps = {
Expand Down Expand Up @@ -2801,16 +2802,18 @@ class w2grid extends w2event {
column = this.last._edit.column
recid = this.last._edit.recid
this.editChange({ type: 'custom', value: this.last._edit.value }, this.get(recid, true), column, event)
let next = event.shiftKey ? this.prevRow(index, column) : this.nextRow(index, column)
if (next != null && next != index) {
setTimeout(() => {
if (this.selectType != 'row') {
this.selectNone()
this.select({ recid: this.records[next].recid, column: column })
} else {
this.editField(this.records[next].recid, column, null, event)
}
}, 1)
if(this.advanceOnEdit) {
let next = event.shiftKey ? this.prevRow(index, column) : this.nextRow(index, column)
if (next != null && next != index) {
setTimeout(() => {
if (this.selectType != 'row') {
this.selectNone()
this.select({ recid: this.records[next].recid, column: column })
} else {
this.editField(this.records[next].recid, column, null, event)
}
}, 1)
}
}
this.last.inEditMode = false
} else {
Expand Down Expand Up @@ -3049,16 +3052,18 @@ class w2grid extends w2event {
}
case 13: { // enter
el.blur()
let next = event.shiftKey ? obj.prevRow(index, column) : obj.nextRow(index, column)
if (next != null && next != index) {
setTimeout(() => {
if (obj.selectType != 'row') {
obj.selectNone()
obj.select({ recid: obj.records[next].recid, column: column })
} else {
obj.editField(obj.records[next].recid, column, null, event)
}
}, 1)
if(obj.advanceOnEdit) {
let next = event.shiftKey ? obj.prevRow(index, column) : obj.nextRow(index, column)
if (next != null && next != index) {
setTimeout(() => {
if (obj.selectType != 'row') {
obj.selectNone()
obj.select({ recid: obj.records[next].recid, column: column })
} else {
obj.editField(obj.records[next].recid, column, null, event)
}
}, 1)
}
}
if (el.tagName.toUpperCase() == 'DIV') {
event.preventDefault()
Expand Down