Foo*_*ack 12 data-binding angularjs angularjs-directive angularjs-scope ng-grid
如何在ng-grid中创建(或访问)所选行的数组?
id | default value | definition
-----------------------------------------------
selectedItems | [] | all of the items selected in the grid.
In single select mode there will only
be one item in the array.
Run Code Online (Sandbox Code Playgroud)
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
<h3>Rows selected</h3>
<pre>{{selectedItems}}</pre>
</body>
Run Code Online (Sandbox Code Playgroud)
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = { data: 'myData' };
});
Run Code Online (Sandbox Code Playgroud)
代码的Plnkr(并运行它)
Ye *_*Liu 23
基于doc,selectedItems应该是属性$scope.gridOptions,所以试试这个:
调节器
$scope.gridOptions = { data: 'myData', selectedItems: [] };
Run Code Online (Sandbox Code Playgroud)
HTML
<pre>{{gridOptions.selectedItems}}</pre>
Run Code Online (Sandbox Code Playgroud)
您可以从以下位置获取ng-grid 2.x的选定项目:
$scope.gridOptions.$gridScope.selectedItems
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40808 次 |
| 最近记录: |