angular-ui/ui-grid

Grid data binding to object property not working

Open

#6,719 创建于 2018年5月5日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)JavaScript (5,395 star) (2,496 fork)batch import
good first issuetype: enhancement

描述

So, ui-grid has this feature:

$scope.data = data; And then direct the grid to resolve whatever is in $scope.data: $scope.gridOptions.data = 'data';

But, when object's property contains data, like, $scope.container.data = [] $scope.gridOptions.data = 'container.data' isn't working.

I have an idea how to fix this:

function getComplexBinding(name, startObj) {
          var path = name.split(/[.\[]/);
          var object = startObj;
          angular.forEach(path, function (val, key) {
              val = val.replace(new RegExp(/['"\]]/, 'g'), '');
              object = object[val];

              if (object == null) {
                  return null;
              }
          });
          if (object === startObj) {
              return null;
          }
          return object;
      }

And replace this line with: newData = getComplexBinding($scope.uiGrid.data, self.grid.appScope);

贡献者指南