0

I have some JSON data that looks like so:

return {
    "activityTypes" :[{
        "id" :"",
        "name:" :"",
        "icon" : "",
        "partial": "",
        "label" : {
            "id": "",
            "name": ""
        }
    }],
    "apiKey" : "",
    "approveBy": 0,
    "approvers" : [], 
    "canSendTo" : [{
        "id" : "",
        "name" : ""
    }],  
    "creators" : [],
    "isActive" : false,
    "notification" : false, 
    "sourceId": "",
    "sourceName":""
};

I am trying to use ng-grid, but I am trouble trying to access the elements inside an array of objects, such as the activityTypes or canSendTo arrays. In the following example, I tried to display canSendTo's id. I've tried the following but it does not render on the screen. Any ideas on how to fix this? Thanks!

{field: 'canSendTo.id', displayName: 'Can Send To', width:'10%',
    cellTemplate: '<div class="ngCellText", style="white-space: normal;">{{row.getProperty(col.field)}}</div>'},

1 Answer 1

1

I don't know anything about ng-grid, but from a straight javascript perspective it should be canSendTo[0].id, since canSendTo is a one element array.

Sign up to request clarification or add additional context in comments.

1 Comment

Hm, I tried your method but unfortunately nothing is displaying. When I use field: 'canSendTo', in every field I get every object (all the contents within it and it looks like [{id: "blah", name: "blah2"}], but I can't seem to get any element within that object (I can't get or display the "blah" field in id by itself).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.