本文介绍了吴格插入几个项目小区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何插入几个值,例如电子邮件,电话和地址,1单元格1单元格。
我需要更少的行,并在细胞中的详细信息。

How to insert several values to 1 cell for example email,phone and adress to 1 cell.I need to make less rows and more info in cells.

我trye​​d这样的方式:

I tryed such way:

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

和seted:

columnDefs: [
            {field:'getNameAndAge()', displayName:'Contacts'}
        ]

但它不为我工作。

but it don't work for me.

我的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": "[email protected]", 
        "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
    }, 

如果我有这样的字段作为朋友,我怎么能显示该数组中的细胞?

And if i have such field as "friends", how i can display this array in cell?

推荐答案

请使用 celltemplate 的每一个细胞,然后用<$ C参考你想要的字段。$ C> row.entity&LT;场及GT; &hellip;下面是一个例子:

Make use of the celltemplate for each cell and then reference the fields you want by using row.entity.<FIELD>…here is an example:

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

这会导致这样一个表:


+----------------------+--------------------------------------------------+
| Name (age)           | Friends                                          |
+----------------------+--------------------------------------------------+
| Rivers Navarro (36)  | Frazier Jefferson, Polly Estes, Klein Cleveland  |
+----------------------+--------------------------------------------------+

这篇关于吴格插入几个项目小区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:47