禁用智能表上的取消选择

时间:2015-07-03 07:13:33

标签: javascript html angularjs smart-table

我有一个这样的智能表:

<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进行滚动事件,所以它&# 39;当想要调用它时取消选择所选行时,这很奇怪。)

1 个答案:

答案 0 :(得分: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);