ng-admin: Showing reference fields in a referenced_list

264 Views Asked by At

Using ng-admin, I have a referenced_list defined as follows against my companies entity to display all the events registered for a company:

    nga.field('companyevents', 'referenced_list') // display list of related profiles
        .label('Company Events')
        .targetEntity(companyEvents) 
        .targetReferenceField('companyid')
        .targetFields([
            nga.field('eventid')
        ])
        .perPage(10)
        .listActions(['edit']),

The target field 'eventid' is itself a reference to an event with an event name. Is there any way I can lookup the event name, rather than just showing the eventid which is pretty meaningless on its own? (E.g. some kind of lookup from a map() call?) When I'm displaying a list view, I can access the event name easily using a reference field:

        nga.field('eventid', 'reference')
            .label('Event')
            .targetEntity(events)
            .targetField(nga.field('eventname')),
1

There are 1 best solutions below

0
On

Is this working?

nga.field('companyevents', 'referenced_list') // display list of related profiles
    .label('Company Events')
    .targetEntity(companyEvents) 
    .targetReferenceField('companyid')
    .targetField(
        nga.field('eventid').map(function (value, entry) {
                        return entry.eventname})
    )
    .perPage(10)
    .listActions(['edit']),