Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Ng网格将多个项目插入单元格_Angularjs_Ng Grid - Fatal编程技术网

Angularjs Ng网格将多个项目插入单元格

Angularjs Ng网格将多个项目插入单元格,angularjs,ng-grid,Angularjs,Ng Grid,如何在一个单元格中插入多个值,例如电子邮件、电话和地址。 我需要在单元格中生成更少的行和更多的信息 我试过这样的方法: angular.forEach($scope.genData,function(row){ row.getNameAndAge = function(){ return this.name + '-' this.age ; } }); 设定为: columnDefs: [ {field:

如何在一个单元格中插入多个值,例如电子邮件、电话和地址。 我需要在单元格中生成更少的行和更多的信息

我试过这样的方法:

 angular.forEach($scope.genData,function(row){
        row.getNameAndAge = function(){
            return this.name + '-' this.age ;
        }
    });
设定为:

columnDefs: [
            {field:'getNameAndAge()', displayName:'Contacts'}
        ]
但这对我不起作用

我的JSON:

{
        "picture": "http://placehold.it/32x32", 
        "about": "Laboris do in mollit nostrud sit tempor ad velit. Duis excepteur ex voluptate dolore elit ad non aliqua. Dolore pariatur non sit eiusmod irure. Aliquip anim officia ea pariatur commodo excepteur. Nisi cupidatat Lorem minim culpa et voluptate commodo duis.\r\n", 
        "guid": "89f8d801-908b-4f9f-a361-d32a0b154451", 
        "name": "Rivers Navarro", 
        "tags": [
            "sit", 
            "pariatur", 
            "non", 
            "eu", 
            "sit", 
            "exercitation", 
            "magna"
        ], 
        "gender": "male", 
        "age": 36, 
        "friends": [
            {
                "id": 0, 
                "name": "Frazier Jefferson"
            }, 
            {
                "id": 1, 
                "name": "Polly Estes"
            }, 
            {
                "id": 2, 
                "name": "Klein Cleveland"
            }
        ], 
        "registered": "2004-05-18T13:23:46 -03:00", 
        "longitude": 79.622006999999996, 
        "email": "riversnavarro@everest.com", 
        "phone": "+1 (972) 552-3807", 
        "address": "962 Grace Court, Neahkahnie, Virginia, 6242", 
        "latitude": -20.004383000000001, 
        "customField": "Hello, Rivers Navarro! You have 4 unread messages.", 
        "balance": "$3,296.00", 
        "company": "Everest", 
        "id": 0, 
        "isActive": true
    }, 

如果我有“friends”这样的字段,我如何在单元格中显示这个数组

为每个单元格使用
单元格模板
,然后使用
行实体引用所需字段。
…以下是一个示例:

var nameAgeCellTemplate = '<div class="ngCellText" ng-class="col.colIndex()">{{row.entity.name}} ({{row.entity.age}})</div>';
var friendsCellTemplate = '<div class="ngCellText" ng-class="col.colIndex()"><span ng-repeat="friend in row.entity.friends">{{friend.name}}{{$last ? '' : ', '}}</span></div>';

$scope.gridOptions = {
  columnDefs: [
    {
      displayName: 'Name (age)',
      cellTemplate: nameAgeCellTemplate
    },
    {
      displayName: 'Friends',
      cellTemplate: friendsCellTemplate
    }
  ]
};
var-nameAgeCellTemplate='{{row.entity.name}}({{row.entity.age}}');
var-friendsCellTemplate='{{friend.name}}{{{$last?'':','}}}';
$scope.gridOptions={
columnDefs:[
{
displayName:“姓名(年龄)”,
cellTemplate:nameAgeCellTemplate
},
{
displayName:'朋友',
cellTemplate:friendsCellTemplate
}
]
};
这将生成如下表:

+----------------------+--------------------------------------------------+ | Name (age) | Friends | +----------------------+--------------------------------------------------+ | Rivers Navarro (36) | Frazier Jefferson, Polly Estes, Klein Cleveland | +----------------------+--------------------------------------------------+ +----------------------+--------------------------------------------------+ |姓名(年龄)|朋友| +----------------------+--------------------------------------------------+ |纳瓦罗河(36)|弗雷泽·杰斐逊、波利·埃斯特斯、克莱恩·克利夫兰| +----------------------+--------------------------------------------------+