public GridColumnAttribute GetAnnotationForColumn <T>(PropertyInfo pi)
        {
            pi = GetMetadataProperty <T>(pi);

            var gridAttr = pi.GetAttribute <GridColumnAttribute>();

            GridColumnAttribute dataAnnotationAttr = gridAttr;

            DataAnnotationsOptions dataAnnotations = ExtractDataAnnotations(pi);

            if (dataAnnotations != null)
            {
                if (gridAttr == null)
                {
                    dataAnnotationAttr = new GridColumnAttribute
                    {
                        Title         = dataAnnotations.DisplayName,
                        FilterEnabled = dataAnnotations.FilterEnabled ?? false,
                        Format        = dataAnnotations.Format
                    };
                }
                else
                {
                    dataAnnotationAttr.Title         = string.IsNullOrEmpty(gridAttr.Title) ? dataAnnotations.DisplayName : gridAttr.Title;
                    dataAnnotationAttr.FilterEnabled = dataAnnotations.FilterEnabled ?? gridAttr.FilterEnabled;
                    dataAnnotationAttr.Format        = string.IsNullOrEmpty(gridAttr.Format) ? dataAnnotations.Format : gridAttr.Format;
                }
            }
            return(dataAnnotationAttr);
        }
Beispiel #2
0
        public GridColumnAttribute GetAnnotationForColumn <T>(PropertyInfo pi)
        {
            pi = GetMetadataProperty <T>(pi);

            var gridAttr = pi.GetAttribute <GridColumnAttribute>();

            if (gridAttr != null)
            {
                return(gridAttr);
            }

            GridColumnAttribute dataAnnotationAttr = null;

            DataAnnotationsOptions dataAnnotations = ExtractDataAnnotations(pi);

            if (dataAnnotations != null)
            {
                dataAnnotationAttr = new GridColumnAttribute
                {
                    Title         = dataAnnotations.DisplayName,
                    FilterEnabled = dataAnnotations.FilterEnabled ?? false,
                    Format        = dataAnnotations.Format
                };
            }
            return(dataAnnotationAttr);
        }