Locode Ref Attribute

I’m walking through the Locode Chinook example. I’ve set the references so the id’s should not display on the grid, but rather the associated labels. I note this works for the update form but the grid still shows the ids. What am I missing to make this work correctly?

 [Ref(Model = nameof(Album), RefId = nameof(AlbumId), RefLabel = nameof(Album.Title))]
        public int? AlbumId { get; set; }
        
        [Ref(Model = nameof(MediaType), RefId = nameof(MediaTypeId), RefLabel = nameof(MediaType.Name))]
        public int MediaTypeId { get; set; }
        
        [Ref(Model = nameof(Genre), RefId = nameof(GenreId), RefLabel = nameof(Genre.Name))]

Hi @linaar,

For custom presentation of column data, the data needs to be in the response payload of the AutoQuery endpoint. This avoids additional fetches for each row and field. To achieve this you will want to use the [References(typeof(Model))] attribute and the [Reference] attribute. When the AutoQuery request is process, this will utilize the LoadSelect APIs to fetch the referenced data in the same request, and it can be used then to populate the values on the Locode UI.

I’ve updated the Tracks model on the Chinook demo to show a use of this, and you can see the result here in the live demo.

Hope that helps.

2 Likes

This is perfect. Thanks for going above and beyond to showcase this scenario.

1 Like