From aaadeb68ccde118035ee147dbbd77d30d283ba98 Mon Sep 17 00:00:00 2001 From: Tony Germaneri Date: Wed, 30 Nov 2016 03:47:08 -0800 Subject: [PATCH] fixed position bug with context menu, fixed find selection data --- lib/main.js | 14 +++++++++----- package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7472c673..71730c58 100644 --- a/lib/main.js +++ b/lib/main.js @@ -272,7 +272,7 @@ define([], function context() { if (rowIndex === -1 || rowIndex === data.length) { return; } d[rowIndex] = []; row.forEach(function (col, colIndex) { - if (colIndex === -1) { return; } + if (col === -1) { return; } d[rowIndex][col] = data[rowIndex][s[col].name]; }); }); @@ -602,6 +602,10 @@ define([], function context() { throw new Error('Cannot sort. No such column name'); } function localeCompare(a, b) { + if (a[columnName] === undefined || a[columnName] === null + || b[columnName] === undefined || b[columnName] === null) { + return false; + } if (asc) { return a[columnName].localeCompare(b[columnName]); } @@ -776,8 +780,8 @@ define([], function context() { contextMenu.style.cursor = 'pointer'; contextMenu.style.position = 'absolute'; contextMenu.style.zIndex = '3'; - contextMenu.style.top = e.clientY + style.contextMenuMarginTop + 'px'; - contextMenu.style.left = e.clientX + style.contextMenuMarginLeft + 'px'; + contextMenu.style.top = pos.y + style.contextMenuMarginTop + 'px'; + contextMenu.style.left = pos.x + style.contextMenuMarginLeft + 'px'; filterInput.value = filterValue || ''; menuItems = []; if (attributes.showFilter) { @@ -1373,7 +1377,7 @@ define([], function context() { controlInput.addEventListener('keypress', keypress, false); controlInput.addEventListener('keyup', keyup, false); controlInput.addEventListener('keydown', keydown, false); - container.addEventListener('mouseup', mouseup, false); + document.body.addEventListener('mouseup', mouseup, false); container.addEventListener('mousedown', mousedown, false); container.addEventListener('dblclick', dblclick, false); container.addEventListener('click', click, false); @@ -1591,4 +1595,4 @@ define([], function context() { return intf; } return grid; -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index 190b6737..6cb39a13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "canvas-datagrid", - "version": "0.9.0", + "version": "0.9.1", "description": "Canvas based data grid", "main": "./lib/main.js", "scripts": {