Ng-grid: how to immediately select a new row

I create an ng grid and dynamically add a new row by pressing a button; however, a new row cannot be selected immediately using the grid options - selectRow .

here is a demo: http://plnkr.co/edit/Kqw68GD09Jqqkrf1svGJ?p=preview

Can anyone help me how to make a new row selected after installing it? Thank.

+3
source share
1 answer

You can try adding watchwith $timeout0:

 $scope.$watch(function () {
       return $scope.myData;
    },
    function (newValue, oldValue) {
     $timeout(function(){
       $scope.gridOptions.selectRow(newValue.length-1,true);
     },0);
    }, true);

Demo Plunker

+3
source

All Articles