This example demonstrates how to use the following attributes to influence columns generated by the GridControl:
-DisplayFormat
-NumericMask
-DateTimeMask
-RegExMask
You can also use the Fluent API mechanism instead of attributes. Create a class implementing the IMetadataProvider interface. In the IMetadataProvider.BuildMetadata method, assign required metadata:
[C#]voidIMetadataProvider<Customer>.BuildMetadata(MetadataBuilder<Customer>builder){builder.Property(p=>p.ID).NumericMask("N0");builder.Property(p=>p.Name).DisplayFormatString("name is: {0}",true);builder.Property(p=>p.Phone).RegExMask(@"\d{2}-\d{2}-\d{2}");builder.Property(p=>p.HiredAt).DateTimeMask("dd/MM/yyyy");}
To register this metadata, use the following code:
[C#]MetadataLocator.Default=MetadataLocator.Create().AddMetadata(typeof(Customer),typeof(DataAnnotationsElement1Metadata));
With this approach, you don't need to modify the model class code. This may be useful if you don't have access to this class code.