角UI电网Coloumndefs错误 [英] Angular Ui grid Coloumndefs bug

查看:265
本文介绍了角UI电网Coloumndefs错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我用下面的code,这是工作的罚款

     <!doctype html>
     <html ng-app="app">
 <head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>
<script src="ht tp://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-touch.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-animate.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
<script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
<script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css">
<link rel="stylesheet" href="main.css" type="text/css">
 </head>
 <body>

 <div ng-controller="MainCtrl">
  <br>
  <br>
  <div id="grid1" ui-grid="gridOptions" class="grid"></div>
  </div>
  <style type="text/css">
         .grid {
   width: 500px;
    height: 200px;
    }
  .red { color: red;  background-color: yellow !important; }
   .blue { color: blue;  }

    </style>

  <script>   
 var app = angular.module('app', ['ui.grid']);
      app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http)     {

        $scope.gridOptions = {
            enableSorting: true,
            columnDefs: [
          { field: 'name', cellClass: 'red' },
          { field: 'company',
              cellClass: function (grid, row, col, rowRenderIndex, colRenderIndex) {
                  if (grid.getCellValue(row, col) === 'Velity') {
                      return 'blue';
                  }
              }
          }
        ];
        };
        $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
        .success(function (data) {
            $scope.gridOptions.data = data;
        });
    } ]);


   </script>
 </body>
</html>

当我使用Columndefs作为变量,这是不工作?
这是在角UI电网中的错误

    <!doctype html>
    <html ng-app="app">
    <head>
    <script    src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.js"></script>
   <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-touch.js">   </script>
   <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-animate.js"> </script>
   <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
 <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
 <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
 <script src="http://ui-grid.info/release/ui-grid-unstable.js"></script>
 <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid-unstable.css" type="text/css">
  <link rel="stylesheet" href="main.css" type="text/css">
 </head>
  <body>

  <div ng-controller="MainCtrl">
 <br>
 <br>
 <div id="grid1" ui-grid="gridOptions" class="grid"></div>
 </div>
  <style type="text/css">
      .grid {
  width: 500px;
  height: 200px;
  }
 .red { color: red;  background-color: yellow !important; }
 .blue { color: blue;  }

  </style>

<script>        var app = angular.module('app', ['ui.grid']);
      app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http)    {
          $scope.cv = [
          { field: 'name', cellClass: 'red' },
          { field: 'company',
                cellClass: function (grid, row, col, rowRenderIndex, colRenderIndex) {
                  if (grid.getCellValue(row, col) === 'Velity') {
                      return 'blue';
                  }
              }
          }
        ];
        $scope.gridOptions = {
            enableSorting: true,
            columnDefs: 'cv'
        };
        $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
        .success(function (data) {
            $scope.gridOptions.data = data;
        });
    } ]);


</script>
  </body>
  </html>

伙计们,如果你知道的话请帮我
我正在采用了棱角分明的UI电网动态模板,我很快得到了这类愚蠢的错误。
我想在角度网格字段添加动态验证将是具有挑战性的任务,但我从来没有想过我会得到这种类型的错误。

Guys if you know, then please help me I was making a dynamic templates using angular ui grid, And I got this type of silly error very soon. I was thinking that adding dynamic validation in angular grid fields would be the challenging task, but i never thought that i will get this type of error.

推荐答案

columnDefs 选项不再接受字符串作为参数。这不是证据充分的,但它的升级指南中提到:的http://用户界面 - grid.info/docs/#/tutorial/099_upgrading_from_2#updatecolumndefs

The columnDefs option no longer accepts a string as an argument. It's not well-documented but it's mentioned in the upgrade guide: http://ui-grid.info/docs/#/tutorial/099_upgrading_from_2#updatecolumndefs

您可以指定无论是命名或匿名数组:

You can assign either a named or anonymous array:

$scope.myColDefs = [...];
$scope.gridOptions.columnDefs = $scope.myColDefs;

// or:

$scope.gridOptions.columnDefs = [...];

这篇关于角UI电网Coloumndefs错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆