UI-Grid无法读取未定义

时间:2016-06-24 03:23:42

标签: angularjs http frontend angular-ui-grid grafana

大家好我正在尝试设置可扩展网格http://ui-grid.info/docs/#/tutorial/216_expandable_grid

但是得到错误哦http请求:

TypeError:无法读取undefined的属性“data”     at new eval(ui-grid.js?bust = 1466737921408:3164)     在Object.invoke(angular.js?bust = 1466737921408:4625)     at $ controllerInit(angular.js?bust = 1466737921408:10027)     at nodeLinkFn(angular.js?bust = 1466737921408:8965)     在eval(angular.js?bust = 1466737921408:9362)     at processQueue(angular.js?bust = 1466737921408:15757)     在eval(angular.js?bust = 1466737921408:15773)     在范围。$ eval(angular.js?bust = 1466737921408:17025)     在Scope。$ digest(angular.js?bust = 1466737921408:16841)     在Scope。$ apply(angular.js?bust = 1466737921408:17133)

这是我的代码:

gridOptions: {
  paginationPageSizes: [25, 50, 75],
  paginationPageSize: 25,
  expandableRowTemplate: '<div ui-grid="row.entity.subGridOptions" style="width: 150px;"></div>',
  onRegisterApi: function(gridApi) {
    console.log('getting here');
    gridApi.expandable.on.rowExpandedStateChanged($scope, $http, function(row) {
      console.log(row);
      if (row.isExpanded) {
        row.entity.subGridOptions = {
          columnDefs: [{
            name: 'name'
          }, {
            name: 'gender'
          }, {
            name: 'company'
          }]
        };

        $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/100.json')
          .success(function(data) {
            row.entity.subGridOptions.data = data[1];
          })
          .error(function(error) {
            console.log(error);
          });
      }
    });
  }
}

0 个答案:

没有答案