0

ui-grid我需要在一行中显示数组中的每个数据。请帮助我,它是否正确?所以data[0]应该显示在一个中ui-griddata[1]应该显示在另一个中ui-grid,所以它ui-grid在一个页面中看起来是多个。但是请针对每种情况帮助我解决这种情况,因为我不知道有多少数据。

控制器.js:

             $rootScope.viewFollowup; // In this am having 'n' of datas only
             $scope.gridView={};

             $scope.data1= $.makeArray($rootScope.viewFollowup[0]);
             $scope.data2= $.makeArray($rootScope.viewFollowup[1]);
             $scope.data3= $.makeArray($rootScope.viewFollowup[2]);
           //$scope.gridOptions -- in this grid options am having all the columndefs                      details 

             $scope.aa=$scope.gridOptions;
             $scope.aa.data= $scope.data1;        

            $scope.ab= $scope.gridOptions;
            $scope.ab.data= $scope.data2;

            $scope.ac=$scope.gridOptions;
            $scope.ac.data=$scope.data3;    

            $scope.gridView=[$scope.aa,$scope.ab,$scope.ac];
            $rootScope.tabledata=$scope.gridView;

HTML:

<div class="row" ng-repeat="group in tabledata track by $index">
    <div ui-grid="group" page-equalheight ui-grid-resize-columns ui-grid-selection ui-grid-auto-resize class="grid" style=style="height:250px"></div>
</div>

输出:

Grid View 1
-------------------------------------------
a| b| c|d|
-------------------------------------------

Grid View 2
-------------------------------------------
c| d| e|f|
-------------------------------------------

    but what am getting is:
  Grid View 1
-------------------------------------------
c| d| e|f|
-------------------------------------------

Grid View 2
-------------------------------------------
c| d| e|f|
-------------------------------------------
4

1 回答 1

0

所有ui-grid需求都是一个gridOptions包含要在网格上显示的数据的对象。您可以将它们gridOptions放在一个数组中,然后在您的标记中使用ng-repeat. 这是一个例子:

var gridOptions1 = {
data: [{
  "name": "Ethel Price",
  "gender": "female",
  "company": "Enersol"
}, {
  "name": "Claudine Neal",
  "gender": "female",
  "company": "Sealoud"
}, {
  "name": "Beryl Rice",
  "gender": "female",
  "company": "Velity"
}, {
  "name": "Wilder Gonzales",
  "gender": "male",
  "company": "Geekko"
}]
};
var gridOptions2 = {
data: [{
  "name": "Georgina Schultz",
  "gender": "female",
  "company": "Suretech"
}, {
  "name": "Carroll Buchanan",
  "gender": "male",
  "company": "Ecosys"
}, {
  "name": "Valarie Atkinson",
  "gender": "female",
  "company": "Hopeli"
}, {
  "name": "Schroeder Mathews",
  "gender": "male",
  "company": "Polarium"
}, {
  "name": "Lynda Mendoza",
  "gender": "female",
  "company": "Dogspa"
  }]

 };

$scope.grids = [gridOptions1, gridOptions2];

然后在你的标记中你可以使用ng-repeat

<div ng-repeat='options in grids'>
  <div id="grid1" ui-grid="options" class="grid"></div>
</div>

是上面示例的工作 plnkr。

于 2016-09-19T18:51:08.847 回答