disable editing if getEditor returns false
This commit is contained in:
parent
b3f281b214
commit
3651f23157
24
dist/frappe-datatable.cjs.js
vendored
24
dist/frappe-datatable.cjs.js
vendored
@ -2298,11 +2298,25 @@ class CellManager {
|
||||
}
|
||||
|
||||
getEditor(colIndex, rowIndex, value, parent) {
|
||||
// debugger;
|
||||
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
|
||||
if (obj && obj.setValue) return obj;
|
||||
const column = this.datamanager.getColumn(colIndex);
|
||||
const row = this.datamanager.getRow(rowIndex);
|
||||
let editor = this.options.getEditor ?
|
||||
this.options.getEditor(colIndex, rowIndex, value, parent, column, row) :
|
||||
this.getDefaultEditor(parent);
|
||||
|
||||
// editing fallback
|
||||
if (editor === false) {
|
||||
// explicitly returned false
|
||||
return false;
|
||||
}
|
||||
if (editor === undefined) {
|
||||
// didn't return editor, fallback to default
|
||||
editor = this.getDefaultEditor(parent);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
getDefaultEditor(parent) {
|
||||
const $input = $.create('input', {
|
||||
class: 'input-style',
|
||||
type: 'text',
|
||||
@ -3347,7 +3361,7 @@ var DEFAULT_OPTIONS = {
|
||||
none: ''
|
||||
},
|
||||
freezeMessage: '',
|
||||
getEditor: () => {},
|
||||
getEditor: null,
|
||||
addSerialNoColumn: true,
|
||||
addCheckboxColumn: false,
|
||||
enableClusterize: true,
|
||||
|
||||
24
dist/frappe-datatable.js
vendored
24
dist/frappe-datatable.js
vendored
@ -2297,11 +2297,25 @@ class CellManager {
|
||||
}
|
||||
|
||||
getEditor(colIndex, rowIndex, value, parent) {
|
||||
// debugger;
|
||||
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
|
||||
if (obj && obj.setValue) return obj;
|
||||
const column = this.datamanager.getColumn(colIndex);
|
||||
const row = this.datamanager.getRow(rowIndex);
|
||||
let editor = this.options.getEditor ?
|
||||
this.options.getEditor(colIndex, rowIndex, value, parent, column, row) :
|
||||
this.getDefaultEditor(parent);
|
||||
|
||||
// editing fallback
|
||||
if (editor === false) {
|
||||
// explicitly returned false
|
||||
return false;
|
||||
}
|
||||
if (editor === undefined) {
|
||||
// didn't return editor, fallback to default
|
||||
editor = this.getDefaultEditor(parent);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
getDefaultEditor(parent) {
|
||||
const $input = $.create('input', {
|
||||
class: 'input-style',
|
||||
type: 'text',
|
||||
@ -3346,7 +3360,7 @@ var DEFAULT_OPTIONS = {
|
||||
none: ''
|
||||
},
|
||||
freezeMessage: '',
|
||||
getEditor: () => {},
|
||||
getEditor: null,
|
||||
addSerialNoColumn: true,
|
||||
addCheckboxColumn: false,
|
||||
enableClusterize: true,
|
||||
|
||||
@ -2297,11 +2297,25 @@ class CellManager {
|
||||
}
|
||||
|
||||
getEditor(colIndex, rowIndex, value, parent) {
|
||||
// debugger;
|
||||
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
|
||||
if (obj && obj.setValue) return obj;
|
||||
const column = this.datamanager.getColumn(colIndex);
|
||||
const row = this.datamanager.getRow(rowIndex);
|
||||
let editor = this.options.getEditor ?
|
||||
this.options.getEditor(colIndex, rowIndex, value, parent, column, row) :
|
||||
this.getDefaultEditor(parent);
|
||||
|
||||
// editing fallback
|
||||
if (editor === false) {
|
||||
// explicitly returned false
|
||||
return false;
|
||||
}
|
||||
if (editor === undefined) {
|
||||
// didn't return editor, fallback to default
|
||||
editor = this.getDefaultEditor(parent);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
getDefaultEditor(parent) {
|
||||
const $input = $.create('input', {
|
||||
class: 'input-style',
|
||||
type: 'text',
|
||||
@ -3346,7 +3360,7 @@ var DEFAULT_OPTIONS = {
|
||||
none: ''
|
||||
},
|
||||
freezeMessage: '',
|
||||
getEditor: () => {},
|
||||
getEditor: null,
|
||||
addSerialNoColumn: true,
|
||||
addCheckboxColumn: false,
|
||||
enableClusterize: true,
|
||||
|
||||
@ -430,11 +430,25 @@ export default class CellManager {
|
||||
}
|
||||
|
||||
getEditor(colIndex, rowIndex, value, parent) {
|
||||
// debugger;
|
||||
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
|
||||
if (obj && obj.setValue) return obj;
|
||||
const column = this.datamanager.getColumn(colIndex);
|
||||
const row = this.datamanager.getRow(rowIndex);
|
||||
let editor = this.options.getEditor ?
|
||||
this.options.getEditor(colIndex, rowIndex, value, parent, column, row) :
|
||||
this.getDefaultEditor(parent);
|
||||
|
||||
// editing fallback
|
||||
if (editor === false) {
|
||||
// explicitly returned false
|
||||
return false;
|
||||
}
|
||||
if (editor === undefined) {
|
||||
// didn't return editor, fallback to default
|
||||
editor = this.getDefaultEditor(parent);
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
getDefaultEditor(parent) {
|
||||
const $input = $.create('input', {
|
||||
class: 'input-style',
|
||||
type: 'text',
|
||||
|
||||
@ -39,7 +39,7 @@ export default {
|
||||
none: ''
|
||||
},
|
||||
freezeMessage: '',
|
||||
getEditor: () => {},
|
||||
getEditor: null,
|
||||
addSerialNoColumn: true,
|
||||
addCheckboxColumn: false,
|
||||
enableClusterize: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user