angular-ui/ui-grid

cellNav.getFocusedCell() always return null on first click

Open

#4,467 opened on 2015年10月3日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)JavaScript (5,395 stars) (2,496 forks)batch import
good first issuegrid-cellNavneeds: analysis

説明

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();
                    });
                }
            };
        }
}
}

]);

コントリビューターガイド