@quantlab/handsontable
Version:
Spreadsheet-like data grid editor that provides copy/paste functionality compatible with Excel/Google Docs
29 lines (23 loc) • 856 B
JavaScript
import { getValidSelection } from './../utils';
export var KEY = 'clear_column';
export default function clearColumnItem() {
return {
key: KEY,
name: 'Clear column',
callback: function callback(key, selection) {
var column = selection.start.col;
if (this.countRows()) {
this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column, 'ContextMenu.clearColumn');
}
},
disabled: function disabled() {
var selected = getValidSelection(this);
if (!selected) {
return true;
}
var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
var rowSelected = entireRowSelection.join(',') == selected.join(',');
return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
}
};
}