存在固定时如何编写行模板

how to write a rowtemplate when pinning exsits

当我同时设置 pinning 和 rowTemplate 时,rowTemplate 在一行中重复 3 次

我觉得是pinning col的影响,不知道怎么解决

这里是 plunker:http://plnkr.co/edit/XoXMbmqa1IjegT1RQ297?p=preview

var app = angular.module('app', ['ngTouch', 'ui.grid', 'ui.grid.pinning']);

app.controller('MainCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) {
  $scope.gridOptions = {};

  $scope.gridOptions.columnDefs = [
    { name:'id', width:50, enablePinning:true, hidePinLeft: false, hidePinRight: true },
    { name:'name', width:100, pinnedLeft:true },
    { name:'age', width:100, pinnedRight:true  },
    { name:'address.street', width:150  },
    { name:'address.city', width:150 },
    { name:'address.state', width:50 },
    { name:'address.zip', width:50 }
  ];
  $scope.gridOptions.rowTemplate='<div>helloworld</div>'
  $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
    .then(function(response) {
      $scope.gridOptions.data = response.data;
    });
}]);
.grid {
  width: 100%;
  height: 400px;
}
<!doctype html>
<html ng-app="app">
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-touch.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-animate.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.7.0/angular-aria.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/lodash.min.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/jszip.min.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/excel-builder.dist.js"></script>
    <script src="http://ui-grid.info/release/ui-grid.js"></script>
    <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
    <link rel="stylesheet" href="main.css" type="text/css">
  </head>
  <body>

<div ng-controller="MainCtrl">
  <div ui-grid="gridOptions" class="grid" ui-grid-pinning></div>
</div>


    <script src="app.js"></script>
  </body>
</html>

我正在尝试用 multi headers 制作一个 table 来显示日期信息,每一行都有一个名称作为第一列,第二列是一个可以显示的折线图业务数据。

I draw a pic to show this

假设您可以不用固定,我会从您的网格中删除固定扩展。这使得使用 header 模板更容易......否则你会 运行 遇到与你的 header 相同的问题(三个重复的 headers)。

看到这个笨蛋:http://plnkr.co/edit/nvuUKIQczdY2E6KuMEVG?p=preview

我删除了固定,删除了 rowTemplate,使用单个 headerCellTemplate(占位符)来容纳您的日历 header,并使用 cellTemplate 来容纳您的图形逻辑。

Html:

<div ng-controller="MainCtrl">
  <div ui-grid="gridOptions" class="grid"></div>
</div>

Javascript:

var app = angular.module('app', ['ngTouch', 'ui.grid']);

app.controller('MainCtrl', ['$scope', '$http', '$log', function ($scope, $http, $log) {
  $scope.gridOptions = {};

  $scope.gridOptions.columnDefs = [
    { field:'id', name:'id', width:'25'},
    { field:'name', name:'name', width:'*' },
    { name:'chart', headerCellTemplate:'<div>Include header code here', width:'*', cellTemplate: '<div>include graph code here</div>'  }
  ];
  $http.get('https://cdn.rawgit.com/angular-ui/ui-grid.info/gh-pages/data/500_complex.json')
    .then(function(response) {
      $scope.gridOptions.data = response.data;
    });
}]);

希望我正确解释了您的目标,希望这对您有所帮助:)