canvas-datagrid 0.3.16 → 0.3.20

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.
@@ -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
@@ -379,6 +416,37 @@ export default function (self) {
379
416
  }
380
417
  self.draw();
381
418
  };
419
+ /**
420
+ * Returns true if indices of columns next to the selected columnIndex is selected on every row.
421
+ * @memberof canvasDatagrid
422
+ * @name isMultiColumnsSelected
423
+ * @method
424
+ * @param {number} columnIndex The column index to check.
425
+ */
426
+ self.isMultiColumnsSelected = function (columnIndex) {
427
+ var multiColIsSelected = true;
428
+ self.viewData.forEach(function (row, rowIndex) {
429
+ var columnIndices = self.selections[rowIndex];
430
+ if (
431
+ !columnIndices ||
432
+ columnIndices.length <= 1 ||
433
+ columnIndices.indexOf(columnIndex) === -1
434
+ ) {
435
+ multiColIsSelected = false;
436
+ } else if (columnIndices.length > 1) {
437
+ if (columnIndices[0] != columnIndex) multiColIsSelected = false;
438
+ else {
439
+ for (var i = 0; i < columnIndices.length - 1; i++) {
440
+ if (columnIndices[i] + 1 != columnIndices[i + 1]) {
441
+ multiColIsSelected = false;
442
+ break;
443
+ }
444
+ }
445
+ }
446
+ }
447
+ });
448
+ return multiColIsSelected;
449
+ };
382
450
  /**
383
451
  * Returns true if the selected columnIndex is selected on every row.
384
452
  * @memberof canvasDatagrid
@@ -391,8 +459,7 @@ export default function (self) {
391
459
  self.viewData.forEach(function (row, rowIndex) {
392
460
  if (
393
461
  !self.selections[rowIndex] ||
394
- self.selections[rowIndex].indexOf(self.orders.columns[columnIndex]) ===
395
- -1
462
+ self.selections[rowIndex].indexOf(columnIndex) === -1
396
463
  ) {
397
464
  colIsSelected = false;
398
465
  }
@@ -504,6 +571,7 @@ export default function (self) {
504
571
  st,
505
572
  en,
506
573
  s = self.getVisibleSchema();
574
+ self.isMultiRowsSelected = false;
507
575
  function de() {
508
576
  if (supressEvent) {
509
577
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "canvas-datagrid",
3
- "version": "0.3.16",
3
+ "version": "0.3.20",
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",