Akshit
Akshit

Reputation: 140

ng-admin identifier not highlighted and entityId not set

I am using ng-admin to build admin panel. However, I ran into a problem while using it. I installed ng-admin using bower. What happens is that I have custom identifier. ListView is populating as I want it to. But my identifier is not highlighted as link to editionview or showView. If I force it to go to showview, entityId is returned as undefined and hence all fields are empty.

This is the configuration I have,

    var payeesList = nga.entity('payees').label('Payees')
            .url('/info/payees').identifier(nga.field('payeeId', 'string'));

    payeesList.creationView().fields([
      nga.field('payeeId', 'string').label('Payee ID').attributes({ placeholder: 'Payee ID in 5-12 char' }).validation({ required: true, minlength: 5, maxlength: 12 }).detailLinkRoute('show'),
      nga.field('payeeName', 'string').label('Payee Name').attributes({ placeholder: 'Payee Name in 50 char' }).validation({ required: true, minlength: 3, maxlength: 50 })
    ]);

    payeesList.listView().fields([
      payeesList.creationView().fields(),
      nga.field('valid', 'boolean').label('Valid').validation({ required: true }),
      nga.field('added', 'datetime').label('Added'),
      nga.field('modified', 'datetime').label('Modified')
    ])
    .infinitePagination(true)
    .batchActions([]);

    payeesList.showView().fields([
      payeesList.listView().fields()
    ])
    .url(function(entityId) {
      return '/info/payees/' + encodeURIComponent(entityId); // entityId is undefined here
    })
    .title('Payee "{{ entry.values.payeeId }}" details');  // payeeId not defined here

    payeesList.deletionView().disable();

    admin.addEntity(payeesList);

Upvotes: 0

Views: 151

Answers (1)

Vincent tim
Vincent tim

Reputation: 1

ng-admin handle string id if your rest controller handle id as string :

  @RequestMapping(value = "/{id}", method= RequestMethod.GET, produces = "application/json")
    public MyEntity showMyEntity(@PathVariable String id, Model model){

And your CRUD service too :

public interface CRUDService<T> {
    List<?> listAll();

    T getById(String id);

Upvotes: 0

Related Questions