I need a column in ui-grid which is a concatenation of two fields,say 'name' and 'address'. How can I achieve this?
Did you try this approach?
var app = angular.module('myApp', ['ngGrid']);
app.controller('MyCtrl', function($scope) {
$scope.myData = [
{name: "Moroni", address: test1},
{name: "Tiancum", address: test2},
{name: "Jacob", address: test3},
{name: "Nephi", address: test4},
{name: "Enos", address: test5 }];
angular.forEach($scope.myData,function(row){
row.getNameAndAddress = function(){
return this.name + '-' + this.address;
}
});
$scope.gridOptions = {
data: 'myData',
columnDefs: [{field: 'name', displayName: 'Name'},
{field:'address', displayName:'Address'},
{field: 'getNameAndAddress()', displayName: 'Name and address'},
]
};
});
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
</body>