Esempio n. 1
0
 private void OnSortChanged()
 {
     if (SortChanged != null)
     {
         SortChanged.Invoke(this, EventArgs.Empty);
     }
 }
        protected virtual async Task OnSortChanged()
        {
            SortEventArgs args = new SortEventArgs();

            args.ColumnName = Grid.Settings.SortSettings.ColumnName;
            args.Direction  = Grid.Settings.SortSettings.Direction;

            if (SortChanged != null)
            {
                await SortChanged.Invoke(this, args);
            }
        }
        public async Task SetNewSortAsync(string sortId, MatSortDirection direction)
        {
            SortId    = sortId;
            Direction = direction;
            await SortIdChanged.InvokeAsync(sortId);

            await DirectionChanged.InvokeAsync(direction);

            await SortChanged.InvokeAsync(new MatSortChangedEvent()
            {
                SortId    = sortId,
                Direction = direction
            });

            this.StateHasChanged();
        }
Esempio n. 4
0
        private void OnHyperLinkClick(object sender, RoutedEventArgs e)
        {
            object new_sort_hyperlink = sender;

            if (sort_hyperlink == new_sort_hyperlink)
            {
                reverse_sort_direction = !reverse_sort_direction;
            }
            else
            {
                reverse_sort_direction = false;
                sort_hyperlink         = new_sort_hyperlink;
            }

            SortChanged?.Invoke();
        }
        /// <summary>
        /// Sort the data by the specified column.
        /// </summary>
        /// <param name="column">The column to sort by.</param>
        /// <remarks>To disable sorting for any given column, set its Sortable property set to false.</remarks>
        protected async Task SortByAsync(PDColumn <TItem> column, SortDirection?direction = null)
        {
            if (column.Sortable && !string.IsNullOrWhiteSpace(column.Id))
            {
                // if direction specified then sort as requested
                if (direction.HasValue)
                {
                    column.SortDirection = direction.Value;
                }
                else
                {
                    // if column already sorted then reverse direction
                    if (column.Id == SortCriteria?.Key)
                    {
                        column.SortDirection = column.SortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending;
                    }
                    else
                    {
                        var previousCol = Columns.Find(x => x.Id == SortCriteria?.Key);
                        if (previousCol != null)
                        {
                            previousCol.SortDirection = SortDirection.None;
                        }
                        column.SortDirection = SortDirection.Ascending;
                    }
                }

                if (SortCriteria != null)
                {
                    SortCriteria.Key       = column.Id;
                    SortCriteria.Direction = column.SortDirection;
                }

                await GetDataAsync().ConfigureAwait(true);

                await SortChanged.InvokeAsync(new SortCriteria { Key = column.Id, Direction = direction ?? column.SortDirection }).ConfigureAwait(true);
            }
        }
Esempio n. 6
0
        private void handleSortClick(HitInfo hitInfo)
        {
            FieldSortInfo sortInfo;

            if (!_sortIndexByField.TryGetValue(hitInfo.FieldName, out int sortIndex))
            {
                sortIndex = -1;
                sortInfo  = null;
            }
            else
            {
                sortInfo = _sortInfos[sortIndex];
            }


            if (ModifierKeys == Keys.None)
            {
                _sortInfos.Clear();
                _sortIndexByField.Clear();

                if (sortInfo == null)
                {
                    sortInfo = new FieldSortInfo(hitInfo.FieldName, SortOrder.Ascending);

                    _sortInfos.Add(sortInfo);
                    _sortIndexByField.Add(hitInfo.FieldName, _sortInfos.Count - 1);
                }
                else if (sortInfo.SortOrder == SortOrder.Ascending)
                {
                    sortInfo.SortOrder = SortOrder.Descending;
                    _sortInfos.Add(sortInfo);
                    _sortIndexByField.Add(hitInfo.FieldName, _sortInfos.Count - 1);
                }

                updateSort();
                SortChanged?.Invoke(this);
            }
            else if (ModifierKeys == Keys.Shift)
            {
                if (sortInfo == null)
                {
                    sortInfo = new FieldSortInfo(hitInfo.FieldName, SortOrder.Ascending);
                    _sortInfos.Add(sortInfo);
                    _sortIndexByField.Add(hitInfo.FieldName, _sortInfos.Count - 1);
                }
                else if (sortInfo.SortOrder == SortOrder.Ascending)
                {
                    sortInfo.SortOrder = SortOrder.Descending;
                }
                else if (sortInfo.SortOrder == SortOrder.Descending)
                {
                    _sortInfos.RemoveAt(sortIndex);
                    _sortIndexByField.Remove(hitInfo.FieldName);
                }

                updateSort();
                SortChanged?.Invoke(this);
            }
            else if (ModifierKeys == Keys.Control)
            {
                if (sortInfo != null)
                {
                    _sortInfos.RemoveAt(sortIndex);
                    _sortIndexByField.Remove(hitInfo.FieldName);

                    updateSort();
                    SortChanged?.Invoke(this);
                }
            }
        }
Esempio n. 7
0
 protected void OnSortChanged(QueryOption obj, bool added)
 {
     SortChanged?.Invoke(obj, added);
 }
Esempio n. 8
0
 public void Invalidate()
 {
     _sortedDocsByDefaultSort.Clear();
     SortChanged?.Invoke();
 }
Esempio n. 9
0
 public void Invalidate()
 {
     _sortedCards = null;
     SortChanged?.Invoke();
 }