Manichandra
Manichandra

Reputation: 185

AngularJS : ui grid show multi lines in a cell

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

Upvotes: 4

Views: 12041

Answers (1)

Kathir
Kathir

Reputation: 6196

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

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

Upvotes: 3

Related Questions