angular-ui/ui-grid

Grid data binding to object property not working

Open

#6.719 geöffnet am 5. Mai 2018

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.496 Forks)batch import
good first issuetype: enhancement

Repository-Metriken

Stars
 (5.395 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide