2

我有一个这样的智能表:

<table id="mytable" st-safe-src="ABCSet" st-table="displayed" class="table table-responsive portlet-body panel-body">
                    <thead>
                        <tr >
                            <th >1</th>
                            <th >2</th>
                            <th >3</th>
                        </tr>
                    </thead>                        
                    <tbody data-ng-dblclick="scrollTo()">    
                        <tr data-ng-repeat="row in displayed" st-select-row="row" st-select-mode="single">
                            <td data-ng-click="$parent.selR(row);">{{row.randomP.randomD}}</td>
                            <td data-ng-click="$parent.selR(row);">{{row.randomP.randomD}}</td>
                            <td data-ng-click="$parent.selR(row);">{{row.randomP.randomD}}</td>
                        </tr>
                    </tbody>
                </table>

它工作正常,但我在表格下的一些标签上显示数据,所以我想在用户单击当前选定的行时禁用取消选择(如您所见,我使用 doubleClick 进行滚动事件,所以当选择的行在想要调用它时被取消选择)。

4

1 回答 1

0

您可以为此使用 ng-watch。

    // get selected row
    $scope.selectedId = 0;
    // fired when table rows are selected
    $scope.$watch('displayedCollection', function (row) {
        row.filter(function (r) {
            if (r.isSelected && r.id != $scope.selectedId) {
                $scope.selectedId = r.id;
                getInfo(r.id);
            }
            else{
                $scope.selectedId = r.id;
            }
        })
    }, true);
于 2015-09-21T20:45:05.467 回答