angular-ui/ui-grid

Grid data binding to object property not working

已關閉

#6,719 建立於 2018年5月5日

 (1 則留言) (0 個反應) (0 位負責人)JavaScript (2,496 個分叉)batch import
good first issuetype: enhancement

倉庫指標

星標
 (5,395 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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

貢獻者指南