从ng网格中获取选择的行? [英] Getting select rows from ng-grid?
本文介绍了从ng网格中获取选择的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How do I create (or access) an array of selected rows in my 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.
index.html
index.html
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
<h3>Rows selected</h3>
<pre>{{selectedItems}}</pre>
</body>
main.js
main.js
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' };
});
Plnkr代码(并运行它)
推荐答案
根据该文档, selectedItems
应该是 $ scope.gridOptions
的属性,所以请尝试:
Based on the doc, selectedItems
should be a property of $scope.gridOptions
, so try this:
控制器
$scope.gridOptions = { data: 'myData', selectedItems: [] };
HTML
<pre>{{gridOptions.selectedItems}}</pre>
这篇关于从ng网格中获取选择的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文