diff --git a/index.html b/index.html
index d1f4742..4caa354 100644
--- a/index.html
+++ b/index.html
@@ -19,6 +19,10 @@
Frappé DataTable
+
@@ -33,43 +37,58 @@
diff --git a/lib/frappe-datatable.js b/lib/frappe-datatable.js
index 391891d..5972a95 100644
--- a/lib/frappe-datatable.js
+++ b/lib/frappe-datatable.js
@@ -1231,7 +1231,7 @@ var CellManager = function () {
colIndex = _$$data6.colIndex;
var col = this.columnmanager.getColumn(colIndex);
- if (col && col.editable === false) {
+ if (col && (col.editable === false || col.focusable === false)) {
return;
}
@@ -1375,7 +1375,9 @@ var CellManager = function () {
}, {
key: 'updateCell',
value: function updateCell(colIndex, rowIndex, value) {
- var cell = this.datamanager.updateCell(colIndex, rowIndex, value);
+ var cell = this.datamanager.updateCell(colIndex, rowIndex, {
+ content: value
+ });
this.refreshCell(cell);
}
}, {
@@ -1921,6 +1923,9 @@ var ColumnManager = function () {
if (!_this9.minWidthMap[colIndex]) {
// only set this once
_this9.minWidthMap[colIndex] = width;
+ _this9.datamanager.updateColumn(colIndex, {
+ minWidth: width
+ });
}
});
}
@@ -1943,6 +1948,7 @@ var ColumnManager = function () {
if (width < minWidth) {
width = minWidth;
}
+ _this10.datamanager.updateColumn(colIndex, { width: width });
_this10.setColumnWidth(colIndex, width);
_this10.setDefaultCellHeight(height);
});
@@ -1972,6 +1978,7 @@ var ColumnManager = function () {
var width = _dom2.default.style(_this11.getColumnHeaderElement(col.colIndex), 'width');
var finalWidth = Math.min(width + deltaWidth) - 2;
+ _this11.datamanager.updateColumn(col.colIndex, { width: finalWidth });
_this11.setColumnHeaderWidth(col.colIndex, finalWidth);
_this11.setColumnWidth(col.colIndex, finalWidth);
});
@@ -2128,7 +2135,7 @@ var _datatable = __webpack_require__(6);
var _datatable2 = _interopRequireDefault(_datatable);
-var _package = __webpack_require__(18);
+var _package = __webpack_require__(19);
var _package2 = _interopRequireDefault(_package);
@@ -2180,58 +2187,16 @@ var _style = __webpack_require__(12);
var _style2 = _interopRequireDefault(_style);
-__webpack_require__(13);
+var _defaults = __webpack_require__(13);
+
+var _defaults2 = _interopRequireDefault(_defaults);
+
+__webpack_require__(14);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-var DEFAULT_OPTIONS = {
- data: {
- columns: [],
- rows: []
- },
- dropdownButton: '▼',
- headerDropdown: [{
- label: 'Sort Ascending',
- action: function action(column) {
- this.sortColumn(column.colIndex, 'asc');
- }
- }, {
- label: 'Sort Descending',
- action: function action(column) {
- this.sortColumn(column.colIndex, 'desc');
- }
- }, {
- label: 'Reset sorting',
- action: function action(column) {
- this.sortColumn(column.colIndex, 'none');
- }
- }, {
- label: 'Remove column',
- action: function action(column) {
- this.removeColumn(column.colIndex);
- }
- }],
- events: {
- onRemoveColumn: function onRemoveColumn(column) {},
- onSwitchColumn: function onSwitchColumn(column1, column2) {},
- onSortColumn: function onSortColumn(column) {}
- },
- sortIndicator: {
- asc: '↑',
- desc: '↓',
- none: ''
- },
- freezeMessage: 'Loading...',
- editing: null,
- addSerialNoColumn: true,
- addCheckboxColumn: true,
- enableClusterize: true,
- enableLogs: false,
- takeAvailableSpace: false
-};
-
var DataTable = function () {
function DataTable(wrapper, options) {
_classCallCheck(this, DataTable);
@@ -2247,10 +2212,10 @@ var DataTable = function () {
throw new Error('Invalid argument given for `wrapper`');
}
- this.options = Object.assign({}, DEFAULT_OPTIONS, options);
- this.options.headerDropdown = DEFAULT_OPTIONS.headerDropdown.concat(options.headerDropdown || []);
+ this.options = Object.assign({}, _defaults2.default, options);
+ this.options.headerDropdown = _defaults2.default.headerDropdown.concat(options.headerDropdown || []);
// custom user events
- this.events = Object.assign({}, DEFAULT_OPTIONS.events, options.events || {});
+ this.events = Object.assign({}, _defaults2.default.events, options.events || {});
this.fireEvent = this.fireEvent.bind(this);
this.prepare();
@@ -2763,19 +2728,40 @@ var DataManager = function () {
}
}, {
key: 'updateCell',
- value: function updateCell(colIndex, rowIndex, value) {
+ value: function updateCell(colIndex, rowIndex, keyValPairs) {
var cell = void 0;
if ((typeof colIndex === 'undefined' ? 'undefined' : _typeof(colIndex)) === 'object') {
- // cell object was passed
+ // cell object was passed,
+ // must have colIndex, rowIndex
cell = colIndex;
colIndex = cell.colIndex;
rowIndex = cell.rowIndex;
- value = cell.content;
+ // the object passed must be merged with original cell
+ keyValPairs = cell;
}
cell = this.getCell(colIndex, rowIndex);
- cell.content = value;
+
+ // mutate object directly
+ for (var key in keyValPairs) {
+ var newVal = keyValPairs[key];
+ if (newVal !== undefined) {
+ cell[key] = newVal;
+ }
+ }
return cell;
}
+ }, {
+ key: 'updateColumn',
+ value: function updateColumn(colIndex, keyValPairs) {
+ var column = this.getColumn(colIndex);
+ for (var key in keyValPairs) {
+ var newVal = keyValPairs[key];
+ if (newVal !== undefined) {
+ column[key] = newVal;
+ }
+ }
+ return column;
+ }
}, {
key: 'getRowCount',
value: function getRowCount() {
@@ -3121,11 +3107,12 @@ var BodyRenderer = function () {
}
}
});
+
this.appendRemainingData();
// setDimensions will work only if there is atleast one row appended
// so we call it as soon as the first Page is appended
this.firstPagePromise.then(function () {
- return _this.instance.setDimensions();
+ _this.instance.setDimensions();
});
}
}, {
@@ -3267,10 +3254,67 @@ module.exports = exports['default'];
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = {
+ data: {
+ columns: [],
+ rows: []
+ },
+ dropdownButton: '▼',
+ headerDropdown: [{
+ label: 'Sort Ascending',
+ action: function action(column) {
+ this.sortColumn(column.colIndex, 'asc');
+ }
+ }, {
+ label: 'Sort Descending',
+ action: function action(column) {
+ this.sortColumn(column.colIndex, 'desc');
+ }
+ }, {
+ label: 'Reset sorting',
+ action: function action(column) {
+ this.sortColumn(column.colIndex, 'none');
+ }
+ }, {
+ label: 'Remove column',
+ action: function action(column) {
+ this.removeColumn(column.colIndex);
+ }
+ }],
+ events: {
+ onRemoveColumn: function onRemoveColumn(column) {},
+ onSwitchColumn: function onSwitchColumn(column1, column2) {},
+ onSortColumn: function onSortColumn(column) {}
+ },
+ sortIndicator: {
+ asc: '↑',
+ desc: '↓',
+ none: ''
+ },
+ freezeMessage: 'Loading...',
+ editing: null,
+ addSerialNoColumn: true,
+ addCheckboxColumn: true,
+ enableClusterize: true,
+ enableLogs: false,
+ takeAvailableSpace: false
+};
+module.exports = exports['default'];
+
+/***/ }),
+/* 14 */
+/***/ (function(module, exports, __webpack_require__) {
+
// style-loader: Adds some css to the DOM by adding a