Пример #1
0
        public void RegisterColumn(IMGridColumn pColumn)
        {
            if (ColumnsList.Any(c => c.Identifier == pColumn.Identifier))
            {
                return;
            }

            ColumnsList.Add(pColumn);

            if (pColumn is MGridActionColumn <T> )
            {
                mHasActionColumn = true;
            }

            if (pColumn is IMGridPropertyColumn propc)
            {
                var iprop = ReflectionHelper.GetIMPropertyInfo(typeof(T), propc.Property, propc.PropertyType);

                propc.PropertyType = iprop.PropertyType;

                if (propc.Attributes != null)
                {
                    iprop.SetAttributes(propc.Attributes);
                }

                mPropertyInfoCache.Add(propc, iprop);

                if (pColumn is IMGridSortableColumn sc && sc.SortDirection != MSortDirection.None)
                {
                    object comparer = null;

                    if (pColumn is IMGridCustomComparer)
                    {
                        comparer = ((dynamic)pColumn).Comparer;
                    }

                    SortInstructions.Add(new SortInstruction()
                    {
                        Direction    = sc.SortDirection,
                        PropertyInfo = iprop,
                        Index        = sc.SortIndex,
                        Comparer     = comparer
                    });
                }
            }

            mFilterModel = null;
            ClearDataCache();
            StateHasChanged();
        }