使用ng-grid过滤器时,ng-grid不会更新

时间:2018-06-22 08:01:16

标签: javascript angularjs angularjs-filter ng-grid

我有一个带有按钮的网格(单元格模板),该按钮显示了带有另一个网格的弹出窗口。问题是,当使用网格过滤器时,网格不会第一次显示数据。如果我关闭网格并再次单击该按钮,则会显示具有更新网格的对话框。第一次不起作用的原因是什么?

点击此编辑按钮时:

enter image description here

$scope.assetGridEditClick = function (row) {
     $scope.AssetSubNodeData = [];
     var obj = row.entity;
     $scope.Id = obj.Id;
     $scope.AssetNumber = obj.AssetNumber;
     $scope.AssetCategoryDescription = obj.AssetDescription;
     $scope.MfrModelNumber = obj.ManufacturerModelNumber;
     $scope.selectedCategoryToSave = obj.AssetCategory;
     $scope.AssetCalRequired = obj.CalibrationRequired;
     $scope.AssetNextCalDate = obj.NextCalibrationDueDate;
     $scope.AssetLastCalDate = obj.LastCalibrationDate;
     $scope.AssetSubNodeFactor = obj.HasSubNode;
     $scope.subnodenumber = "";
     $scope.AssetSubNodeData = angular.copy(obj.AssetSubNode);
     $scope.AssetStatus = obj.AssetStatus;
     $scope.uuid = obj.uuid;
     $scope.IsDeleted = obj.IsDeleted;
     $scope.editAsset = true;

     $scope.$apply();
 },

弹出窗口中的网格代码

$scope.SubNodeListGridOptions = {
        columnDefs: [
                    {
                        field: "Id",
                        displayName: "Id",
                        width: '0%',
                        visible: false
                    },
                    {
                        field: "AssetsId",
                        displayName: "Asset Id",
                        visible: false

                    },
                    {
                        field: "AssetsNumber",
                        displayName: "Asset Number",
                        visible: false

                    },
                    {
                        field: "AssetSubNodeNumber",
                        displayName: "Sub-Node Number",
                        enableCellEdit: false,
                        cellTemplate: '<input type="textbox" class="form-control" data-ng-model="row.entity.AssetSubNodeNumber" ng-show="row.entity.Editmode">' +
                              '<span class="form-control" ng-show="!row.entity.Editmode">{{row.entity.AssetSubNodeNumber}}<span>'
                    },
                    {
                        field: "LastModified",
                        displayName: "Last Modified Date",
                        enableCellEdit: false,
                        visible:false,
                        cellTemplate: '<span class="form-control">{{row.entity.LastModified}}<span>'
                    },
                    {
                        field: "uuid",
                        displayName: "uuid",
                        visible: false
                    },
                    {
                        field: "IsDeleted",
                        displayName: "IsDeleted",
                        visible: false
                    },
                    {
                        field: "",
                        width: '10%',
                        cellTemplate: '<a class="btn btn-primary" style="width:50%;" data-ng-click="subnodeGridEditClick(row)" ng-show="!row.entity.Editmode">' +
                                      '<span class="glyphicon glyphicon-edit"></span> </a>' +
                                      '<a class="btn btn-primary" style="width:50%;" data-ng-click="gridUpdateSubnodeEntry(row)" ng-show="row.entity.Editmode">' +
                                      '<span class="glyphicon glyphicon-ok"></span> </a>' +
                                      '<a class="btn btn-primary" style="width:50%;" data-ng-click="subNodeGridCancelClick(row)" ng-show="row.entity.Editmode">' +
                                      '<span class="glyphicon glyphicon-remove"></span> </a>' +
                                      '<a class="btn btn-primary1" style="width:50%;" data-ng-click="grdRemoveSubNodeEntry(row)" ng-show="true" data-toggle="tooltip" title="Remove Entry">' +
                                      '<span class="glyphicon glyphicon-minus-sign" style="color:#cc0000"></span></a>'
                    }],
        data: 'AssetSubNodeData',
        enableColumnResize: true,
        enableRowSelection: true,
        multiSelect: false,
        filterOptions: $scope.filterOptions
    };
    $scope.filterOptions = {
        filterText: 'IsDeleted:False'
        //useExternalFilter: true
    };

任何帮助表示赞赏。谢谢

0 个答案:

没有答案