ng-admin

Reference type field with derived display field


In ng-admin I am able to add a field of type reference and display the name of the referenced entity by

nga.field('schedule', 'reference')
  .targetEntity(schedule)
  .targetField(nga.field('name'))
  .label('Schedule'),

Is it possible to display a derived field of the referenced entity, say name (id)?

I tried using .template() with no luck.


Solution

  • You'll have to use map(), as seen in the Posters galore demo:

    nga.field('schedule', 'reference')
      .targetEntity(schedule)
      .targetField(nga.field('name').map((v, e) => e.name + ' (' + e.id + ')'))
      .label('Schedule')