Question

I have an entity with the following fields in the server side metadata class:

Partial Friend Class CustomerMetadata
    <Required()> _
    <Display(Order:=1, Name:="First Name")> _
    Public Property FirstName As String

    <Required()> _
    <Display(Order:=2, Name:="Last Name")> _
    Public Property LastName As String

    <Required()> _
    <Display(Order:=3, Description:="Phone")> _
    Property DisplayPhone As String

    <Required()> _
    <Display(Order:=4, Name:="Email Address")> _
    Public Property EmailAddress As String
End Class

Now in the client, I want to swap the display order of the Phone and Email address fields in a datagrid, so I create a new client side CustomerMetadata class like such:

Partial Friend Class CustomerMetadata
    <Required()> _
    <Display(Order:=4, Description:="Phone")> _
    Property DisplayPhone As String

    <Required()> _
    <Display(Order:=3, Name:="Email Address")> _
    Public Property EmailAddress As String
End Class

The client doesn't pick up the overridden display order. Any ideas on how to override the Display attribute in the client side metadata class?

Was it helpful?

Solution

It's not possible to override the metadata in the client that you set on the server.

In particular, the RIA Services concept of metadata classes is a server-side one - and only used when using Entity Framework with the model-first-approach where you have the designer create your entity classes). The attributes you put on the metadata classes on the server will be auto-generated during build as attributes on the actual entities on the client.

Since the ordering attributes are the only way I know of to control the DataGrid ordering when using auto-generated columns, I can only think of two ways to evade the issue:

  1. Specify the columns in your grid explicitly (in the end you probably have to anyway for a host of reasons, auto-generated columns are rarely sufficient in practice) or
  2. use the same ordering in both the client and the server entities.

(For the sake of completion I should mention that you can also fiddle with the way RIA Services client code is auto-generated, but that would be inappropriate for the problem you're having.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top