AngularJS : ui grid show multi lines in a cell

11,594

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

Share:
11,594
Manichandra
Author by

Manichandra

Updated on June 29, 2022

Comments

  • Manichandra
    Manichandra almost 2 years

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