Esempio n. 1
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            if (!Sortable)
            {
                Sortable = SorterMultiple != default || SorterCompare != default || Sort != default;
            }

            if (IsHeader)
            {
                if (FieldExpression != null)
                {
                    _propertyReflector = PropertyReflector.Create(FieldExpression);
                    if (Sortable)
                    {
                        SortModel = new SortModel <TData>(_propertyReflector.Value.PropertyInfo, SorterMultiple, Sort, SorterCompare);
                    }
                }
                else
                {
                    (GetValue, SortModel) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
                }
            }
            else if (IsBody)
            {
                SortModel     = Context.HeaderColumns[ColIndex] is IFieldColumn fieldColumn ? fieldColumn.SortModel : null;
                (GetValue, _) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
            }

            ClassMapper
            .If("ant-table-column-has-sorters", () => Sortable)
            .If($"ant-table-column-sort", () => Sortable && SortModel != null && SortModel.SortType.IsIn(SortType.Ascending, SortType.Descending));
        }
Esempio n. 2
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            Sortable = Sortable || SorterMultiple != default || SorterCompare != default || DefaultSortOrder != default || SortDirections?.Any() == true;

            if (IsHeader)
            {
                if (FieldExpression != null)
                {
                    var paramExp = Expression.Parameter(ItemType);
                    var member   = ColumnExpressionHelper.GetReturnMemberInfo(FieldExpression);
                    var bodyExp  = Expression.MakeMemberAccess(paramExp, member);
                    GetFieldExpression = Expression.Lambda(bodyExp, paramExp);
                }
                else if (DataIndex != null)
                {
                    (_, GetFieldExpression) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
                }

                if (Sortable && GetFieldExpression != null)
                {
                    SortModel = new SortModel <TData>(GetFieldExpression, SorterMultiple, DefaultSortOrder, SorterCompare);
                }

                if (GetFieldExpression != null)
                {
                    var member = ColumnExpressionHelper.GetReturnMemberInfo(GetFieldExpression);
                    DisplayName = member.GetCustomAttribute <DisplayNameAttribute>(true)?.DisplayName ?? member.Name;
                    FieldName   = member.Name;
                }
            }
            else if (IsBody)
            {
                SortModel = Context.HeaderColumns[ColIndex] is IFieldColumn fieldColumn ? fieldColumn.SortModel : null;

                (GetValue, _) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
            }

            SortDirections ??= Table.SortDirections;

            Sortable       = Sortable || SortModel != null;
            _sortDirection = SortModel?.SortDirection ?? DefaultSortOrder ?? SortDirection.None;

            ClassMapper
            .If("ant-table-column-has-sorters", () => Sortable)
            .If($"ant-table-column-sort", () => Sortable && SortModel != null && SortModel.SortDirection.IsIn(SortDirection.Ascending, SortDirection.Descending));
        }
Esempio n. 3
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            Sortable = Sortable || SorterMultiple != default || SorterCompare != default || DefaultSortOrder != default || SortDirections?.Any() == true;

            if (IsHeader)
            {
                if (FieldExpression != null)
                {
                    _propertyReflector = PropertyReflector.Create(FieldExpression);
                }

                if (Sortable)
                {
                    if (_propertyReflector.HasValue)
                    {
                        SortModel = new SortModel <TData>(_propertyReflector.Value.PropertyInfo, SorterMultiple, DefaultSortOrder, SorterCompare);
                    }
                    else
                    {
                        (GetValue, SortModel) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
                    }
                }
            }
            else if (IsBody)
            {
                SortModel = Context.HeaderColumns[ColIndex] is IFieldColumn fieldColumn ? fieldColumn.SortModel : null;

                (GetValue, _) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
            }

            SortDirections ??= Table.SortDirections;

            Sortable       = Sortable || SortModel != null;
            _sortDirection = SortModel?.SortDirection ?? DefaultSortOrder ?? SortDirection.None;

            ClassMapper
            .If("ant-table-column-has-sorters", () => Sortable)
            .If($"ant-table-column-sort", () => Sortable && SortModel != null && SortModel.SortDirection.IsIn(SortDirection.Ascending, SortDirection.Descending));
        }
Esempio n. 4
0
        protected override void OnInitialized()
        {
            base.OnInitialized();

            Sortable = Sortable || SorterMultiple != default || SorterCompare != default || DefaultSortOrder != default || SortDirections?.Any() == true;

            if (IsHeader)
            {
                if (FieldExpression != null)
                {
                    var paramExp = Expression.Parameter(ItemType);
                    var member   = ColumnExpressionHelper.GetReturnMemberInfo(FieldExpression);
                    var bodyExp  = Expression.MakeMemberAccess(paramExp, member);
                    GetFieldExpression = Expression.Lambda(bodyExp, paramExp);
                }
                else if (DataIndex != null)
                {
                    (_, GetFieldExpression) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
                }

                if (GetFieldExpression != null)
                {
                    var member = ColumnExpressionHelper.GetReturnMemberInfo(GetFieldExpression);
                    DisplayName = member.GetCustomAttribute <DisplayNameAttribute>(true)?.DisplayName ?? member.GetCustomAttribute <DisplayAttribute>(true)?.GetName() ?? member.Name;
                    FieldName   = DataIndex ?? member.Name;
                }

                if (Sortable && GetFieldExpression != null)
                {
                    SortModel = new SortModel <TData>(GetFieldExpression, FieldName, SorterMultiple, DefaultSortOrder, SorterCompare);
                }
            }
            else if (IsBody)
            {
                SortModel = Context.HeaderColumns[ColIndex] is IFieldColumn fieldColumn ? fieldColumn.SortModel : null;

                (GetValue, _) = ColumnDataIndexHelper <TData> .GetDataIndexConfig(this);
            }

            SortDirections ??= Table.SortDirections;

            Sortable       = Sortable || SortModel != null;
            _sortDirection = SortModel?.SortDirection ?? DefaultSortOrder ?? SortDirection.None;

            if (Filters?.Any() == true)
            {
                Filterable        = true;
                _columnFilterType = TableFilterType.List;
            }
            else if (Filterable)
            {
                _columnDataType = THelper.GetUnderlyingType <TData>();
                if (_columnDataType == typeof(bool))
                {
                    _columnFilterType = TableFilterType.List;

                    Filters = new List <TableFilter <TData> >();

                    var trueFilterOption = GetNewFilter();
                    trueFilterOption.Text  = Table.Locale.FilterOptions.True;
                    trueFilterOption.Value = THelper.ChangeType <TData>(true);
                    ((List <TableFilter <TData> >)Filters).Add(trueFilterOption);
                    var falseFilterOption = GetNewFilter();
                    falseFilterOption.Text  = Table.Locale.FilterOptions.False;
                    falseFilterOption.Value = THelper.ChangeType <TData>(false);
                    ((List <TableFilter <TData> >)Filters).Add(falseFilterOption);
                }
                else
                {
                    _columnFilterType = TableFilterType.FeildType;
                    InitFilters();
                }
            }

            ClassMapper
            .If("ant-table-column-has-sorters", () => Sortable)
            .If($"ant-table-column-sort", () => Sortable && SortModel != null && SortModel.SortDirection.IsIn(SortDirection.Ascending, SortDirection.Descending));
        }