private void InitializeGridProperties()
        {
            var collectionProperties    = GridEntityConfiguration.ClrTypeCollectionProperties;
            var propertiesListWithOrder = new List <(int Order, PropertyInfo Prop)>();

            foreach (var property in GridItemProperties)
            {
                if (collectionProperties.Contains(property))
                {
                    continue;
                }

                var columnConfig     = GridEntityConfiguration.FindColumnConfiguration(property.Name);
                var columnVisibility = columnConfig?.IsVisible;
                if (columnVisibility.HasValue && !columnVisibility.Value)
                {
                    continue;
                }

                var            columnOrder          = columnConfig == null ? GridColumnAnotations.DefaultOrder : columnConfig.Order;
                ValueFormatter columnValueFormatter = columnConfig?.ValueFormatter ?? new DefaultValueFormatter();

                propertiesListWithOrder.Add((Order: columnOrder, Prop: property));
                valueFormatters.Add(property.Name, columnValueFormatter);
            }

            GridItemProperties = propertiesListWithOrder.OrderBy(p => p.Order)
                                 .Select(p => p.Prop)
                                 .ToList();
        }
Beispiel #2
0
        public void InitializeGridProperties(List <PropertyInfo> itemProperties)
        {
            if (itemProperties is null)
            {
                throw new ArgumentNullException(nameof(itemProperties));
            }

            var collectionProperties    = GridEntityConfiguration.ClrTypeCollectionProperties;
            var propertiesListWithOrder = new List <(int Order, PropertyInfo Prop)>();

            foreach (var property in itemProperties)
            {
                var columnConfig = GridEntityConfiguration.FindColumnConfiguration(property.Name);

                if (columnConfig == null && GridConfiguration.OnlyShowExplicitProperties)
                {
                    continue;
                }

                PermissionContext.ResolveColumnPermission(columnConfig, property.Name);

                if (columnConfig?.ValueFormatter == null && collectionProperties.Contains(property))
                {
                    continue;
                }

                var columnVisibility = columnConfig?.IsVisible;
                if (columnVisibility.HasValue && !columnVisibility.Value)
                {
                    continue;
                }

                var columnOrder          = columnConfig == null ? GridColumnAnnotations.DefaultOrder : columnConfig.Order;
                var columnValueFormatter = columnConfig?.ValueFormatter ?? new DefaultValueFormatter();

                propertiesListWithOrder.Add((Order: columnOrder, Prop: property));
                _valueFormatters.Add(property.Name, columnValueFormatter);

                if (columnConfig?.SpecialColumnValue != null)
                {
                    _columnRendererFragments.Add(property.Name, columnConfig.SpecialColumnValue);
                }

                if (columnConfig?.ColumnEditComponentBuilder != null)
                {
                    _columnEditRendererBuilders.Add(property.Name, columnConfig.ColumnEditComponentBuilder);
                }
            }

            GridItemProperties = propertiesListWithOrder.OrderBy(p => p.Order)
                                 .Select(p => p.Prop)
                                 .ToList();
        }
        private void InitializeGridProperties()
        {
            var propertiesListWithOrder = new List <(int Order, PropertyInfo Prop)>();

            foreach (var property in GridItemProperties)
            {
                ValueFormatter columnValueFormatter = new DefaultValueFormatter();
                var            columnOrder          = GridColumnAnotations.DefaultOrder;
                var            columnConfig         = GridEntityConfiguration.FindColumnConfiguration(property.Name);
                if (columnConfig != null)
                {
                    columnOrder          = columnConfig.Order;
                    columnValueFormatter = columnConfig.ValueFormatter;
                }

                propertiesListWithOrder.Add((Order: columnOrder, Prop: property));
                valueFormatters.Add(property.Name, columnValueFormatter);
            }

            GridItemProperties = propertiesListWithOrder.OrderBy(p => p.Order)
                                 .Select(p => p.Prop)
                                 .ToList();
        }