canvas-datagrid 0.3.19 → 0.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/main.js CHANGED
@@ -9,6 +9,7 @@ import events from './events';
9
9
  import touch from './touch';
10
10
  import intf from './intf';
11
11
  import contextMenu from './contextMenu';
12
+ import button from './button';
12
13
  import dom from './dom';
13
14
  import publicMethods from './publicMethods';
14
15
 
@@ -21,6 +22,7 @@ var modules = [
21
22
  touch,
22
23
  intf,
23
24
  contextMenu,
25
+ button,
24
26
  dom,
25
27
  publicMethods,
26
28
  ];
@@ -206,6 +206,18 @@ export default function (self) {
206
206
  delete self.columnFilters[column];
207
207
  } else {
208
208
  self.columnFilters[column] = value;
209
+ if (self.attributes.showFilterInCell) {
210
+ self.filterable.rows.push(0);
211
+ self.orders.columns.forEach(function (value, index) {
212
+ self.filterable.columns.push(index);
213
+ });
214
+ }
215
+ }
216
+ if (!Object.keys(self.columnFilters).length) {
217
+ self.filterable = {
218
+ rows: [],
219
+ columns: [],
220
+ };
209
221
  }
210
222
  self.refresh();
211
223
  };
@@ -294,6 +306,31 @@ export default function (self) {
294
306
  self.gotoRow = function (y) {
295
307
  self.gotoCell(0, y);
296
308
  };
309
+ /**
310
+ * Add a button into the cell.
311
+ * @memberof canvasDatagrid
312
+ * @name addButton
313
+ * @method
314
+ * @param {number} columnIndex The column index of the cell to to add a button.
315
+ * @param {number} rowIndex The row index of the cell to to add a button.
316
+ * @param {object} offset Offset how far go away from cell.
317
+ * @param {object} items a list of items to add into button menu.
318
+ * @param {string} imgSrc icon path to add into button.
319
+ */
320
+ self.addButton = function (columnIndex, rowIndex, offset, items, imgSrc) {
321
+ var cells = self.visibleCells.filter(function (c) {
322
+ return c.sortColumnIndex === columnIndex && c.sortRowIndex === rowIndex;
323
+ });
324
+
325
+ self.attachButton(
326
+ {
327
+ top: cells[0].y + cells[0].height + offset.y,
328
+ left: cells[0].x + cells[0].width + offset.x,
329
+ },
330
+ items,
331
+ imgSrc,
332
+ );
333
+ };
297
334
  /**
298
335
  * Scrolls the cell at cell x, row y into view if it is not already.
299
336
  * @memberof canvasDatagrid
@@ -697,9 +734,23 @@ export default function (self) {
697
734
  if (!self.canvas) {
698
735
  return;
699
736
  }
700
- self.sizes.columns[
701
- name === 'cornerCell' ? -1 : self.getHeaderByName(name).index
702
- ] = Math.max(self.findColumnMaxTextLength(name), self.style.minColumnWidth);
737
+
738
+ const columnIndex =
739
+ name === 'cornerCell' ? -1 : self.getHeaderByName(name).index;
740
+
741
+ const newSize = Math.max(
742
+ self.findColumnMaxTextLength(name),
743
+ self.style.minColumnWidth,
744
+ );
745
+
746
+ self.sizes.columns[columnIndex] = newSize;
747
+
748
+ self.dispatchEvent('resizecolumn', {
749
+ x: newSize,
750
+ y: self.resizingStartingHeight,
751
+ draggingItem: self.currentCell,
752
+ });
753
+
703
754
  if (!internal) {
704
755
  self.resize();
705
756
  self.draw(true);
@@ -819,6 +870,26 @@ export default function (self) {
819
870
  });
820
871
  self.selections = sel;
821
872
  };
873
+ /**
874
+ * Deletes currently selected data.
875
+ * @memberof canvasDatagrid
876
+ * @name deleteSelectedData
877
+ * @method
878
+ * @param {boolean} dontDraw Suppress the draw method after the selection change.
879
+ */
880
+ self.deleteSelectedData = function (dontDraw) {
881
+ const affectedCells = self.clearSelectedCells();
882
+
883
+ self.dispatchEvent('afterdelete', {
884
+ cells: affectedCells,
885
+ });
886
+
887
+ if (dontDraw) {
888
+ return;
889
+ }
890
+
891
+ requestAnimationFrame(() => self.draw());
892
+ };
822
893
  /**
823
894
  * Moves data in the provided selection to another position in the grid. Moving data off the edge of the schema (columns/x) will truncate data.
824
895
  * @memberof canvasDatagrid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-datagrid",
3
- "version": "0.3.19",
3
+ "version": "0.3.23",
4
4
  "description": "Canvas based data grid web component. Capable of displaying millions of contiguous hierarchical rows and columns without paging or loading, on a single canvas element.",
5
5
  "main": "./dist/canvas-datagrid.js",
6
6
  "module": "./dist/canvas-datagrid.module.js",