multiselect on row causing handleKeyDown error
I'm using a second ui-grid table in modal dialog. I followed the 'selection' example to allow multiSelect. Here's my setup: $scope.gridOptionNodes = { enabledColumnResize: true, enableRowSelection: true, enableRowHeaderSelection: false, multiSelect: true, modifierKeysToMultiSelect: true, enableHighlighting: false };
But when I use Ctrl or Shift for multi-select rows, Chrome debugger gives me error: Uncaught TypeError: Cannot read property 'handleKeyDown' of undefined (ui-grid.js:11412)
I'm using rc-16 build. The source code as: // Bind to keydown events in the render container $elm.on('keydown', function (evt) { evt.uiGridTargetRenderContainerId = containerId; return uiGridCtrl.cellNav.handleKeyDown(evt); });
Do I have to disable multiSelect? How could I get rid of this error? Or is it because I'm using the wrong build?
Thanks
I am not aware of things changing in this area recently, so I doubt it's a wrong build.
Any chance of a short plunker demonstrating the issue? It sounds like the cell doesn't exist for some reason, but not sure why. Does it do it on the tutorial for the selection feature?
Sorry for delay. I'm trying to use the data I just created plunker for it, same code, but it works fine. Although I have another table on my non-modal page. Wonder if some conflict:
http://plnkr.co/edit/D8btFH4eG5M0bIQkSNCY
In my browser debugger that has the error, it's caused from jquery and end up in ui-grid: module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants', function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants) { return { replace: true, priority: -99999, //this needs to run very last require: ['^uiGrid', 'uiGridRenderContainer'], scope: false, compile: function () { return { pre: function ($scope, $elm, $attrs, uiGridCtrl) { }, post: function ($scope, $elm, $attrs, controllers) { var uiGridCtrl = controllers[0], renderContainerCtrl = controllers[1];
var containerId = renderContainerCtrl.containerId;
var grid = uiGridCtrl.grid;
// Needs to run last after all renderContainers are built
uiGridCellNavService.decorateRenderContainers(grid);
// Let the render container be focus-able
$elm.attr("tabindex", -1);
// Bind to keydown events in the render container
$elm.on('keydown', function (evt) {
evt.uiGridTargetRenderContainerId = containerId;
return uiGridCtrl.cellNav.handleKeyDown(evt);
});
This "uiGridCtrl.cellNav" is undefined. And it's an JQuery event: 3 characters selected
Pause On Caught Exceptions
Watch Expressions
uiGridCtrl: $get.Constructor
uiGridCtrl.cellNav: undefined
controllers:
Is there a way I can disable jQuery handle 'keydown' event? Thanks.
OK. I found the difference between rc-16 ui-grid.js and current unstable ui-grid: module.directive('uiGridRenderContainer', ['$timeout', '$document', 'gridUtil', 'uiGridConstants', 'uiGridCellNavService', 'uiGridCellNavConstants', function ($timeout, $document, gridUtil, uiGridConstants, uiGridCellNavService, uiGridCellNavConstants) { return { replace: true, priority: -99999, //this needs to run very last require: ['^uiGrid', 'uiGridRenderContainer', '?^uiGridCellnav'], scope: false, compile: function () { return { post: function ($scope, $elm, $attrs, controllers) { var uiGridCtrl = controllers[0], renderContainerCtrl = controllers[1], -->not in rc-16 cellNavController = controllers[2];
-->not in rc-16 // Skip attaching cell-nav specific logic if the directive is not attached above us -->not in rc-16 if (!cellNavController) { return; }
var containerId = renderContainerCtrl.containerId;
var grid = uiGridCtrl.grid;
// Needs to run last after all renderContainers are built
uiGridCellNavService.decorateRenderContainers(grid);
// Let the render container be focus-able
$elm.attr("tabindex", -1);
// Bind to keydown events in the render container
$elm.on('keydown', function (evt) {
evt.uiGridTargetRenderContainerId = containerId;
return uiGridCtrl.cellNav.handleKeyDown(evt);
});
So during multiple select, it never reach 'keydown', it just return by the 3rd new line "not in rc-16".
Looking forward to a newer build then.
Closing as the change has been released with RC's 17 and 18.