示例#1
0
        private void OnHeaderClicked(TableViewColumnBase column)
        {
            if (!column.SortingEnabled)
            {
                return;
            }

            if (SortedColumn == column)
            {
                // If column is already sorted, change the direction
                SortDirection = SortDirection switch
                {
                    SortDirection.Ascending => SortDirection.Descending,
                    SortDirection.Descending => SortDirection.None,
                    _ => SortDirection.Ascending
                };

                if (SortDirection == SortDirection.None)
                {
                    SortedColumn = null;
                }
            }
            else
            {
                // Set the column to be sorted by ascending order
                SortedColumn  = column;
                SortDirection = SortDirection.Ascending;
            }

            EnsureItemsAreSorted();
        }
示例#2
0
 private string?GetHeaderClass(TableViewColumnBase column)
 {
     return(ClassBuilder.Create("tv-cell-inner", "tv-cell-action", ClassNames.BorderRounded)
            .AddMultiple(new[] { "sortable", ClassNames.HoverDefault, ClassNames.ActiveDefault }, column.Header != null && column.SortingEnabled)
            .Add("sorted-" + (SortDirection == SortDirection.Descending ? "desc" : "asc"), column == SortedColumn)
            .Build());
 }
示例#3
0
        public void RemoveColumn(TableViewColumnBase value)
        {
            value.ThrowIfNull();

            if (_columnDefinitions.Remove(value))
            {
                value.PropertyChanged -= OnColumnPropertyChanged;
                ColumnChanged?.Invoke(value, EventArgs.Empty);
            }
        }
示例#4
0
        public void AddColumn(TableViewColumnBase value)
        {
            value.ThrowIfNull();

            if (!_columnDefinitions.Add(value))
            {
                throw new ApplicationException($"Passed column '{value.GetType().FullName}' was already defined. Ensure each column gets defined only once.");
            }

            value.PropertyChanged += OnColumnPropertyChanged;
            ColumnChanged?.Invoke(value, EventArgs.Empty);
        }