angular-ui/ui-grid

Grid data binding to object property not working

Open

#6 719 ouverte le 5 mai 2018

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (2 496 forks)batch import
good first issuetype: enhancement

Métriques du dépôt

Stars
 (5 395 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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);

Guide contributeur