AngularJS:ui网格在一个单元格中显示多行

问题描述:

我正在尝试在一个单元格中显示多个电话号码.我想在新行中显示每个数字.我尝试了多种方法,但无法弄清楚.有人能帮忙吗 .以下是指向我的plnkr的链接.

i am trying to display multiple phone numbers in one cell . I want to display each number in a new line . I have tried multiple ways but I am unable to figure out. can anyone help with this . below is the link to my plnkr .

http://plnkr.co/edit/LXdiDqoOAYQoO5BW02WR?p=preview

.filter('phoneListFilter', function () {
    return function (telePhoneList) {
        var telePhoneArray = [];

        for (var i in telePhoneList) {
                telePhoneArray.push(telePhoneList[i]);
        }
        return telePhoneArray.join('<br>');
    };
})

您可以通过使用自定义模板并重复您拥有的电话号码来实现.

You can achieve this by having a custom template and repeat over the number of phone numbers you have.

app.controller('MainCtrl', ['$scope', '$http', function ($scope, $http) {
  $scope.gridOptions = {
    rowHeight:50,
    columnDefs: [
      { field: 'name' },
      { field: 'phoneList', name: 'Phone Numbers', cellTemplate:'<div ng-repeat="item in row.entity[col.field]">{{item}}</div>'}
    ],
     enableColumnResizing: true
  };

  $http.get('data.json')
  .success(function (data) {
    $scope.gridOptions.data = data;
  });
}]);

高度可能成为问题.看看这个plnkr http://plnkr.co/edit/c65CZm19bGJbWfZT15u6?p=preview

The height may become an issue. Take a look at this plnkr http://plnkr.co/edit/c65CZm19bGJbWfZT15u6?p=preview