Skip to content

Commit

Permalink
adding Event to Datatable.onEditor callbacks Issue primefaces#1577
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisPiip committed Sep 14, 2020
1 parent 377d2f3 commit dbab00b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/components/datatable/BodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ export class BodyCell extends Component {
onKeyDown(event) {
if (this.props.editMode !== 'row') {
if (event.which === 13 || event.which === 9) { // tab || enter
this.switchCellToViewMode(true);
this.switchCellToViewMode(true, event);
}
if (event.which === 27) // escape
{
this.switchCellToViewMode(false);
this.switchCellToViewMode(false, event);
}
}
}

onClick() {
onClick(event) {
if (this.props.editMode !== 'row') {
this.editingCellClick = true;

Expand All @@ -53,7 +53,7 @@ export class BodyCell extends Component {
editing: true
}, () => {
if (this.props.onEditorInit) {
this.props.onEditorInit(this.props);
this.props.onEditorInit(this.props, event);
}
});

Expand All @@ -64,9 +64,9 @@ export class BodyCell extends Component {
}
}

onBlur() {
onBlur(event) {
if (this.props.editMode !== 'row' && this.state.editing && this.props.editorValidatorEvent === 'blur') {
this.switchCellToViewMode(true);
this.switchCellToViewMode(true, event);
}
}

Expand All @@ -78,7 +78,7 @@ export class BodyCell extends Component {
if (!this.documentEditListener) {
this.documentEditListener = (event) => {
if (!this.editingCellClick) {
this.switchCellToViewMode(true);
this.switchCellToViewMode(true, event);
}

this.editingCellClick = false;
Expand All @@ -101,19 +101,19 @@ export class BodyCell extends Component {
this.unbindDocumentEditListener();
}

switchCellToViewMode(submit) {
switchCellToViewMode(submit, event) {
if (!submit && this.props.onEditorCancel) {
this.props.onEditorCancel(this.props);
this.props.onEditorCancel(this.props, event);
}

let valid = true;
if (this.props.editorValidator) {
valid = this.props.editorValidator(this.props);
valid = this.props.editorValidator(this.props, event);
}

if (valid) {
if (submit && this.props.onEditorSubmit) {
this.props.onEditorSubmit(this.props);
this.props.onEditorSubmit(this.props, event);
}

this.closeCell();
Expand Down

0 comments on commit dbab00b

Please sign in to comment.