Tin*_*ink 3 angularjs angular-ui-grid
我需要一个ui-grid中的列,它是两个字段的串联,比如'name'和'address'.我怎样才能做到这一点?
你尝试过这种方法吗?
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'},
]
};
});
Run Code Online (Sandbox Code Playgroud)
<body ng-controller="MyCtrl">
<div class="gridStyle" ng-grid="gridOptions"></div>
</body>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3283 次 |
| 最近记录: |