从ui-grid中的行中选择一些实体

时间:2016-10-02 17:11:27

标签: angularjs angular-ui-grid

我的网格中有时只有几列,我隐藏了一些只有两个可见的列。我想只用这两个实体(可见)选择行并将它们传递给数组。在此示例中,日期和结果。有没有具体的方法来做到这一点?因为我用的时候 chartData数组中的vm.chartData.push($scope.gridApi.selection.getSelectedRows())我有所有实体。 这是我的控制器代码。

(function () { "use strict";

angular.module("app")
.controller("grid", grid);

function grid($scope) {
    var vm = this;
    vm.chartData = [];

    $scope.gridOptions =
    {
        enableGridMenu: true,
        enableSorting: true,
        enableRowSelection: true,
        selectionRowHeaderWidth: 35,
        enableSelectAll: true,
        multiSelect: true,
        columnDefs: [
          { name: 'Trial', field: 'Trial' },
          { name: 'Date', field: 'Date', type: "date", cellFilter: "date:'dd-MM-yyyy HH:mm'" },
          { name: 'Result', field: 'Result'}
        ],
        data: [
            //example of row entities
            { 
                "Trial": "Weight",
                "Date": "2015-02-03T05:49:54.850Z",
                "Result": 60 
            }
        ]
    };
    $scope.pushAll = function () {
        //this line returns all three entities
        vm.chartData.push($scope.gridApi.selection.getSelectedRows());

    };
    $scope.gridOptions.onRegisterApi = function (gridApi) { 
        $scope.gridApi = gridApi;
    };

}

0 个答案:

没有答案