gpt4 book ai didi

angularjs - 从 ng-grid 获取选择行?

转载 作者:行者123 更新时间:2023-12-02 19:16:16 25 4
gpt4 key购买 nike

如何在我的 ng-grid 中创建(或访问)选定行的数组?

<小时/>

Documentation (滚动到“网格选项”)

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 for the code (并运行它)

最佳答案

根据文档,selectedItems 应该是 $scope.gridOptions 的属性,因此请尝试以下操作:

Controller

$scope.gridOptions = { data: 'myData', selectedItems: [] };

HTML

<pre>{{gridOptions.selectedItems}}</pre>

关于angularjs - 从 ng-grid 获取选择行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16875283/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com