Пример #1
0
        protected override IGridCellBuilder CreateHeaderBuilderCore()
        {
            IGridCellBuilder builder = null;

            HeaderHtmlAttributes.Add("data-field", Member);
            HeaderHtmlAttributes.Add("data-title", Title);
            if (!Groupable)
            {
                HeaderHtmlAttributes.Add("data-groupable", "false");
            }

            AppendAggregateAttributes();

            if (Sortable && Grid.Sortable.Enabled && !HeaderTemplate.HasValue())
            {
                builder = new GridSortableHeaderCellBuilder(HeaderHtmlAttributes, GetSortUrl(), SortDirection, AppendHeaderContent);
            }
            else
            {
                builder = base.CreateHeaderBuilderCore();
            }

            if (Filterable && Grid.Filterable.Enabled && !Grid.ColumnMenu.Enabled)
            {
                var filtered = Grid.DataSource.Filters
                               .SelectMemberDescriptors()
                               .Any(filter => filter.Member.IsCaseInsensitiveEqual(Member));

                builder.Decorators.Add(new GridFilterCellDecorator(filtered));
            }

            return(builder);
        }
Пример #2
0
        private void AppendAggregateAttributes()
        {
            var aggregates = Grid.DataSource.Aggregates
                             .Where(agg => agg.Member == Member)
                             .SelectMany(agg => agg.Aggregates)
                             .Select(agg => agg.AggregateMethodName.ToLowerInvariant());

            if (aggregates.Any())
            {
                HeaderHtmlAttributes.Add("data-aggregates", String.Join(",", aggregates.ToArray()));
            }
        }