仅从单个网格中选择 - 多个ng-grid

时间:2015-01-13 21:20:33

标签: javascript angularjs ng-grid

我有一个要求,其中有两个网格,我想限制用户在任何时间点仅选择单个网格(并且只有一行)。

/**
        * function generates data mart schedule grid option
        * 
        * @public
        * @returns (object) grid options
        **/
        systemReportsConfigOptions: function () {
            return {
                data: "systemReports",
                editable: false,
                enableSorting: false,
                enableRowSelection: true,
                multiSelect: false,
                columnDefs: [{
                    field: "reportName",
                    displayName: "System Reports",
                    //width: 'auto',
                    cellTemplate: '<div  ng-click="onSystemReportsGridSelect()" ng-bind="row.getProperty(col.field)"></div>'
                }],
                height: '100',
                keepLastSelected: false
            };
        },
        /**
        * function generates report config grid option
        * 
        * @public
        * @returns (object) grid options
        **/
        userReportsConfigOptions: function ()
        {
            return {
                data: "userReports",
                editable: false,
                enableSorting: false,
                enableRowSelection: true,
                multiSelect: false,
                columnDefs: [{
                    field: "reportName",
                    displayName: "User-Defined Reports",
                    //width: 'auto',
                    cellTemplate: '<div  ng-click="onUserReportsGridSelect()" ng-bind="row.getProperty(col.field)"></div>'
                }],
                height: '100',
                keepLastSelected: false
            };
        },

这是我的网格选择处理代码:

/**
   * function at selecting System Reports grid
   * 
   * @private
   **/
    function onSystemReportsGridSelect() {
        //debugger;
        $scope.userReportsConfigOptions.selectAll(false);

        $scope.selectedReport = { reportId: this.row.entity.reportId, reportName: this.row.entity.reportName };

        $scope.deleteButtonDisabled = false;
    };

    /**
   * function at selecting User-Defined Reports grid
   * 
   * @private
   **/
    function onUserReportsGridSelect() {
        //debugger;
        $scope.systemReportsConfigOptions.selectAll(false);

        $scope.selectedReport = { reportId: this.row.entity.reportId, reportName: this.row.entity.reportName };

        $scope.deleteButtonDisabled = false;
    };

选择以非常不一致的方式进行。有时它允许选择两个网格中的行。但是当我深入研究时,它只显示了之前的选择,而不是当前的选择。

任何帮助将不胜感激!

0 个答案:

没有答案