angular-ui/ui-grid

cellNav.getFocusedCell() always return null on first click

已關閉

#4,467 建立於 2015年10月3日

 (5 則留言) (0 個反應) (0 位負責人)JavaScript (2,496 個分叉)batch import
good first issuegrid-cellNavneeds: analysis

倉庫指標

星標
 (5,395 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

I am building a directive to copy & paste data from clipboard to ui-grid and vice versa. When trying to get cell values by invoking uiGridCtrl.grid.api.cellNav.getFocusedCell(), I always get null on first click.

I confirmed the issue occur on Firefox, IE, and Chrome. Is there a work around solution to this problem?

--- console.log output --- null copy.js?v=1002:118 d {row: b, col: d} copy.js?v=1002:118 d {row: b, col: d} copy.js?v=1002:118 d {row: b, col: d} copy.js?v=1002:118 d {row: b, col: d} copy.js?v=1002:118 d {row: b, col: d} copy.js?v=1002:118 d {row: b, col: d}

--- directive codes ---

app.directive('uiGridCell', ['gridUtil', '$compile','$interval',
function (gridUtil, $compile, $interval) {

    return {
        replace: true,
        priority: -99999, //this needs to run very last
        require: '^uiGrid',
        scope: false,
        compile: function() {
            return {
                pre: function($scope, $element, $attrs, uiGridCtrl) {

                    $element.on('mousedown', function(e)
                    {
                        e.preventDefault();
                        console.log(uiGridCtrl.grid.api.cellNav.getFocusedCell());
                    });
                    $scope.$on('$destroy', function () {
                        $element.off();
                    });
                }
            };
        }
}
}

]);

貢獻者指南