Immer wählen Sie die Zeilen aus ng-grid?

Wie erstelle ich (oder access) ein array der ausgewählten Zeilen in meiner ng-raster?


Dokumentation (scrollen Sie zu "Raster-Optionen")

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

<body ng-controller="MyCtrl">
    <div class="gridStyle" ng-grid="gridOptions"></div>

    <h3>Rows selected</h3>
    <pre>{{selectedItems}}</pre>
</body>

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 für den code (und ausführen)

InformationsquelleAutor Foo Stack | 2013-06-01

Schreibe einen Kommentar