关键AngularJS变化多行选择NG格属性下降 [英] AngularJS Change multiple row selection ng-grid attribute on key down
问题描述
我在我的视图定义下面的网格
I have a following grid defined in my View
<div class="gridStyle hide" ng-grid="resultsOptions" id="resultsGrid"></div>
和我想允许多选只有当Ctrl键是pssed $ P $。所以我定义多选在控制器属性为假。
And I want to allow multiSelect only if a ctrl key is pressed. So I define multiSelect attribute as false in the Controller.
$scope.resultsOptions = {
data: 'searchData',
selectedItems: $scope.mySelections,
multiSelect: false,
enableHighlighting: true,
enableRowSelection: true
};
在同一个控制器我有以下的code,设置多选设置为true。
In the same controller I have the following code that sets multiSelect to true.
$("#resultsGrid").keydown(function (e) {
if (e.ctrlKey) {
$scope.resultsOptions.multiSelect = true;
$scope.$apply();
}
});
当我启动pressing后ctrl应用多选值的变化。但我仍然无法进行多种选择。
When I launch the application multiSelect value changes after pressing ctrl. But I am still can not make a multiple selection.
我试图用变量多选,但美国能源部不会改变任何事情。
I tried to use variable for multiSelect, but it doe not change a thing.
下面的例子也不会改变多选属性。但它改变了网格标题。
http://plnkr.co/edit/RwYSG4?p=$p$pview一>
The following example also does not change multiSelect attribute. But it changes the grid header. http://plnkr.co/edit/RwYSG4?p=preview
有没有什么简单的解决办法?或者有什么做我在code错过?
Is there any simple solution? Or what do I miss in my code?
推荐答案
既然是不可能改变的飞行电网的一些选项
( https://github.com/angular-ui/ng-grid/issues/ 386 )。我决定手动取消每一个元素,如果CTRL不是pssed $ P $ beforeSelectionChange 网格的属性。
Since it is impossible to change some grid options on the fly (https://github.com/angular-ui/ng-grid/issues/386). I decided to manually deselect every element if ctrl is not pressed in beforeSelectionChange attribute of the grid.
解决方案是的Durty,但它的作品。
The solution is durty, but it works.
根据金马碧的评论的...
Based of mabi's comment...
- Without support for Shift key
- With support for Shift key
这篇关于关键AngularJS变化多行选择NG格属性下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!