Skip to content

dont render input if getEditor returns false #18

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
38 changes: 14 additions & 24 deletions dist/frappe-datatable.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ function objectToString(value) {
var _objectToString = objectToString;

/** `Object#toString` result references. */
var nullTag = '[object Null]';
var undefinedTag = '[object Undefined]';
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';

/** Built-in value references. */
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
Expand Down Expand Up @@ -469,8 +469,8 @@ var toNumber_1 = toNumber;
var FUNC_ERROR_TEXT = 'Expected a function';

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
var nativeMin = Math.min;
var nativeMax = Math.max,
nativeMin = Math.min;

/**
* Creates a debounced function that delays invoking `func` until after `wait`
Expand Down Expand Up @@ -742,16 +742,6 @@ function getDefault(a, b) {
return a !== undefined ? a : b;
}











function copyTextToClipboard(text) {
// https://stackoverflow.com/a/30810322/5353542
var textArea = document.createElement('textarea');
Expand Down Expand Up @@ -813,7 +803,7 @@ function isNumeric(val) {

let throttle$1 = throttle_1;

let debounce$2 = debounce_1;
let debounce$1 = debounce_1;

function promisify(fn, context = null) {
return (...args) => {
Expand All @@ -825,9 +815,6 @@ function promisify(fn, context = null) {
});
};
}



function linkProperties(target, source, properties) {
const props = properties.reduce((acc, prop) => {
acc[prop] = {
Expand Down Expand Up @@ -1662,7 +1649,7 @@ class ColumnManager {
});
});
};
$.on(this.header, 'keydown', '.data-table-filter', debounce$2(handler, 300));
$.on(this.header, 'keydown', '.data-table-filter', debounce$1(handler, 300));
}

sortRows(colIndex, sortOrder) {
Expand Down Expand Up @@ -2105,15 +2092,15 @@ class CellManager {
}
}

this.$editingCell = $cell;
$cell.classList.add('editing');

const $editCell = $('.edit-cell', $cell);
$editCell.innerHTML = '';

const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell);

if (editor) {
this.$editingCell = $cell;
$cell.classList.add('editing');

this.currentCellEditor = editor;
// initialize editing input with cell value
editor.initValue(cell.content, rowIndex, col);
Expand All @@ -2134,6 +2121,10 @@ class CellManager {
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
if (obj && obj.setValue) return obj;

// let the getEditor method determine dynamically
// if the cell is editable or not
if (obj === false) return null;

// editing fallback
const $input = $.create('input', {
class: 'input-style',
Expand Down Expand Up @@ -2666,7 +2657,6 @@ class BodyRenderer {
return rows.map((row) => this.rowmanager.getRowHTML(row, { rowIndex: row[0].rowIndex }));
}
}

function getBodyHTML(rows) {
return `
<tbody>
Expand Down Expand Up @@ -3189,7 +3179,7 @@ var author = "Faris Ansari";
var license = "MIT";
var bugs = {"url":"https://github.com/frappe/datatable/issues"};
var homepage = "https://frappe.github.io/datatable";
var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","sortablejs":"^1.7.0"};
var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","rollup":"^0.56.3","sortablejs":"^1.7.0"};
var packageJson = {
name: name,
version: version,
Expand Down
38 changes: 14 additions & 24 deletions dist/frappe-datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ function objectToString(value) {
var _objectToString = objectToString;

/** `Object#toString` result references. */
var nullTag = '[object Null]';
var undefinedTag = '[object Undefined]';
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';

/** Built-in value references. */
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
Expand Down Expand Up @@ -468,8 +468,8 @@ var toNumber_1 = toNumber;
var FUNC_ERROR_TEXT = 'Expected a function';

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
var nativeMin = Math.min;
var nativeMax = Math.max,
nativeMin = Math.min;

/**
* Creates a debounced function that delays invoking `func` until after `wait`
Expand Down Expand Up @@ -741,16 +741,6 @@ function getDefault(a, b) {
return a !== undefined ? a : b;
}











function copyTextToClipboard(text) {
// https://stackoverflow.com/a/30810322/5353542
var textArea = document.createElement('textarea');
Expand Down Expand Up @@ -812,7 +802,7 @@ function isNumeric(val) {

let throttle$1 = throttle_1;

let debounce$2 = debounce_1;
let debounce$1 = debounce_1;

function promisify(fn, context = null) {
return (...args) => {
Expand All @@ -824,9 +814,6 @@ function promisify(fn, context = null) {
});
};
}



function linkProperties(target, source, properties) {
const props = properties.reduce((acc, prop) => {
acc[prop] = {
Expand Down Expand Up @@ -1661,7 +1648,7 @@ class ColumnManager {
});
});
};
$.on(this.header, 'keydown', '.data-table-filter', debounce$2(handler, 300));
$.on(this.header, 'keydown', '.data-table-filter', debounce$1(handler, 300));
}

sortRows(colIndex, sortOrder) {
Expand Down Expand Up @@ -2104,15 +2091,15 @@ class CellManager {
}
}

this.$editingCell = $cell;
$cell.classList.add('editing');

const $editCell = $('.edit-cell', $cell);
$editCell.innerHTML = '';

const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell);

if (editor) {
this.$editingCell = $cell;
$cell.classList.add('editing');

this.currentCellEditor = editor;
// initialize editing input with cell value
editor.initValue(cell.content, rowIndex, col);
Expand All @@ -2133,6 +2120,10 @@ class CellManager {
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
if (obj && obj.setValue) return obj;

// let the getEditor method determine dynamically
// if the cell is editable or not
if (obj === false) return null;

// editing fallback
const $input = $.create('input', {
class: 'input-style',
Expand Down Expand Up @@ -2665,7 +2656,6 @@ class BodyRenderer {
return rows.map((row) => this.rowmanager.getRowHTML(row, { rowIndex: row[0].rowIndex }));
}
}

function getBodyHTML(rows) {
return `
<tbody>
Expand Down Expand Up @@ -3188,7 +3178,7 @@ var author = "Faris Ansari";
var license = "MIT";
var bugs = {"url":"https://github.com/frappe/datatable/issues"};
var homepage = "https://frappe.github.io/datatable";
var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","sortablejs":"^1.7.0"};
var dependencies = {"clusterize.js":"^0.18.0","lodash":"^4.17.5","rollup":"^0.56.3","sortablejs":"^1.7.0"};
var packageJson = {
name: name,
version: version,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"clusterize.js": "^0.18.0",
"lodash": "^4.17.5",
"rollup": "^0.56.3",
"sortablejs": "^1.7.0"
}
}
10 changes: 7 additions & 3 deletions src/cellmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,15 @@ export default class CellManager {
}
}

this.$editingCell = $cell;
$cell.classList.add('editing');

const $editCell = $('.edit-cell', $cell);
$editCell.innerHTML = '';

const editor = this.getEditor(colIndex, rowIndex, cell.content, $editCell);

if (editor) {
this.$editingCell = $cell;
$cell.classList.add('editing');

this.currentCellEditor = editor;
// initialize editing input with cell value
editor.initValue(cell.content, rowIndex, col);
Expand All @@ -388,6 +388,10 @@ export default class CellManager {
const obj = this.options.getEditor(colIndex, rowIndex, value, parent);
if (obj && obj.setValue) return obj;

// let the getEditor method determine dynamically
// if the cell is editable or not
if (obj === false) return null;

// editing fallback
const $input = $.create('input', {
class: 'input-style',
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,10 @@ rollup-pluginutils@^2.0.1:
estree-walker "^0.3.0"
micromatch "^2.3.11"

rollup@^0.56.3:
version "0.56.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.56.3.tgz#7900695531afa1badd3235f285cc4aa0d49ce254"

run-async@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389"
Expand Down