/// <summary> /// Protected method which raises the sorting event and does default sort /// </summary> /// <param name="eventArgs"></param> protected virtual void OnSorting(DataGridSortingEventArgs eventArgs) { eventArgs.Handled = false; if (Sorting != null) { Sorting(this, eventArgs); } if (!eventArgs.Handled) { DefaultSort( eventArgs.Column, /* clearExistinSortDescriptions */ (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift); } }
protected override void OnSorting(DataGridSortingEventArgs eventArgs) { base.OnSorting(eventArgs); UpdateSorting(); }
private void _ProductsGrid_Sorting(object sender, DataGridSortingEventArgs e) { }
private void BlueprintsSorting(object sender, DataGridSortingEventArgs e) { string realHeader; if (headers.ContainsKey(e.Column)) { realHeader = headers[e.Column]; } else { if (e.Column.Header is TextBlock textBlock) { headers[e.Column] = realHeader = textBlock.Text; } else { headers[e.Column] = realHeader = e.Column.Header.ToString(); } } var view = CollectionViewSource.GetDefaultView(Blueprints.Items); var sortingOn = view.SortDescriptions.ToList(); var path = e.Column.SortMemberPath; var currentSorting = sortingOn.FirstOrDefault(p => p.PropertyName == path); if (currentSorting.PropertyName != null) { int currentColumnSortRank; if (currentSorting.Direction == ListSortDirection.Descending && lastColumnSorted == e.Column) { view.SortDescriptions.Clear(); foreach (var c in Blueprints.Columns) { if (headers.ContainsKey(c)) { c.Header = headers[c]; } } sortedColumns = currentColumnSortRank = 1; } else { currentColumnSortRank = e.Column.Header.ToString().Count(c => c == '↑' || c == '↓'); view.SortDescriptions.Remove(currentSorting); } ListSortDirection newDirection; string newHeader; switch (currentSorting.Direction) { case ListSortDirection.Descending: newDirection = ListSortDirection.Ascending; var upArrows = string.Concat(Enumerable.Repeat("↑", currentColumnSortRank)); newHeader = $"{upArrows}{realHeader}"; break; case ListSortDirection.Ascending: default: newDirection = ListSortDirection.Descending; var downArrows = string.Concat(Enumerable.Repeat("↓", currentColumnSortRank)); newHeader = $"{downArrows}{realHeader}"; break; } e.Column.Header = newHeader; view.SortDescriptions.Add(new SortDescription(path, newDirection)); } else { sortedColumns++; var upArrows = string.Concat(Enumerable.Repeat("↑", sortedColumns)); e.Column.Header = $"{upArrows}{realHeader}"; view.SortDescriptions.Add(new SortDescription(path, ListSortDirection.Ascending)); } view.Refresh(); lastColumnSorted = e.Column; e.Handled = true; }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; SortDataGrid(e.Column); }
public static Func <IEnumerable <T>, IOrderedEnumerable <T> > HandleDataGridSorting <T>(DataGridSortingEventArgs e, IDictionary <string, Func <T, IComparable> > sortSelectors) { e.Handled = true; if (e.Column.SortDirection == null) { e.Column.SortDirection = ListSortDirection.Ascending; } else if (e.Column.SortDirection == ListSortDirection.Ascending) { e.Column.SortDirection = ListSortDirection.Descending; } else { e.Column.SortDirection = null; } return(GetSorting(e.Column, sortSelectors)); }
private void dataGrid1_Sorting(object sender, DataGridSortingEventArgs e) { sortMemberPath = e.Column.SortMemberPath; sortDirection = e.Column.SortDirection != ListSortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending; }
private static void GridOnSorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { //TODO: Need to impl.sk }
private void TermsGrid_Sorting(object sender, DataGridSortingEventArgs e) { IsSorted = true; }
/// <summary>Sorts the column in descending order first, if it's not already sorted. Used for columns containing stats.</summary> /// <param name="sender">The sender.</param> /// <param name="e"> /// The <see cref="DataGridSortingEventArgs" /> instance containing the event data. /// </param> public static void StatColumn_Sorting(DataGrid sender, DataGridSortingEventArgs e) { var namesNotToSortDescendingFirst = new List <string> { "Player", "Last Name", "First Name", "Team", "Name", "Location", "Returns", "Injury" }; if (e.Column.Header.ToString() == "Returns") { e.Handled = true; e.Column.SortDirection = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView((sender).ItemsSource); lcv.CustomSort = e.Column.SortDirection == ListSortDirection.Ascending ? new PlayerInjuryDaysComparerAsc() : new PlayerInjuryDaysComparerDesc(); } else if (e.Column.Header.ToString() == "Injury") { e.Handled = true; e.Column.SortDirection = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView((sender).ItemsSource); lcv.CustomSort = e.Column.SortDirection == ListSortDirection.Ascending ? new PlayerInjuryNameComparerAsc() : new PlayerInjuryNameComparerDesc(); } else if (e.Column.Header.ToString() == "Team") { e.Handled = true; e.Column.SortDirection = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView((sender).ItemsSource); lcv.CustomSort = e.Column.SortDirection == ListSortDirection.Ascending ? new TeamNameComparerAsc() : new TeamNameComparerDesc(); } else if (e.Column.Header.ToString() == "Streak") { e.Handled = true; e.Column.SortDirection = (e.Column.SortDirection != ListSortDirection.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending; var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView((sender).ItemsSource); lcv.CustomSort = e.Column.SortDirection == ListSortDirection.Ascending ? new TeamStreakComparerAsc() : new TeamStreakComparerDesc(); } else if (e.Column.SortDirection == null && e.Column.Header.ToString().Contains("Position") == false) { if (namesNotToSortDescendingFirst.Contains(e.Column.Header) == false) { e.Column.SortDirection = ListSortDirection.Ascending; } } }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { m_dataContext.SortData(e.Column.SortMemberPath); }
// Event: Devices_DataGrid_Sorting private void Devices_DataGrid_Sorting_Handler(object sender, DataGridSortingEventArgs evt) { evt.Handled = Devices_SetComparer((ListCollectionView)Devices_ViewSource.View, evt.Column); Devices_SelectNone(); }
private void SelectedItemBindableDataGrid_Sorting(object sender, DataGridSortingEventArgs e) { }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; DataGrid dg = sender as DataGrid; ListCollectionView lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(dg.ItemsSource); if (e.Column.SortMemberPath == "Item") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("Item", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("Item", 1); } } else if (e.Column.SortMemberPath == "From") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("From", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("From", 1); } } else if (e.Column.SortMemberPath == "To") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("To", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("To", 1); } } else if (e.Column.SortMemberPath == "NumItems") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("NumItems", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("NumItems", 1); } } else if (e.Column.SortMemberPath == "Price") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("Price", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("Price", 1); } } else if (e.Column.SortMemberPath == "Profit") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("Profit", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("Profit", 1); } } else if (e.Column.SortMemberPath == "ROI") { ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending; e.Column.SortDirection = direction; if (direction == ListSortDirection.Ascending) { lcv.CustomSort = new HaulingDataGridComparer("ROI", 0); } else { lcv.CustomSort = new HaulingDataGridComparer("ROI", 1); } } }
private void OnSort(object sender, DataGridSortingEventArgs e) { var col = e.Column; }
public void Sorting(DataGridSortingEventArgs args) { RefreshData(); }
private void Grid_Sorting(object sender, DataGridSortingEventArgs e) { sortIndex = e.Column.DisplayIndex; }
//排序前事件 private void dgProductData_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }
private void Report_Sorting(object sender, DataGridSortingEventArgs e) { }
private void DataGridSorting(object sender, DataGridSortingEventArgs e) { ViewModel.Sort = DataGridHelper.HandleDataGridSorting(e, sortSelectors); }
private void Accounts_Sorting(object sender, DataGridSortingEventArgs e) { var a = e; }
private void DataGridAccountSummarySorting(object sender, DataGridSortingEventArgs e) { sortingDirection = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; sortingColumnName = e.Column.SortMemberPath; columnIndex = e.Column.DisplayIndex; }
private void repairOrderList_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }
private void DataGrid_OnSorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }
private void DataGridSorting(object sender, DataGridSortingEventArgs e) { ViewModel.Sort = DataGridHelper.HandleDataGridSorting <Person>(e); }
private void dgCorrales_Sorting(object sender, DataGridSortingEventArgs e) { dgCorrales.SelectedItem = null; }
private void dataGridOptionView_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; //Cancel user sorting }
private void DataGridSorting(object sender, DataGridSortingEventArgs e) { this.sortComparer.ToggleColumn((DataGridTextColumn)e.Column, (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift); this.TruthTable.CustomSort = this.sortComparer.IsEmpty ? null : this.sortComparer; e.Handled = true; }
private void Customers_Sorting(object sender, DataGridSortingEventArgs e) { ApplySortColumn(e.Column); e.Handled = true; }
/// <summary> /// Method to perform sorting on datagrid /// </summary> /// <param name="sortColumn"></param> internal void PerformSort(DataGridColumn sortColumn) { Debug.Assert(sortColumn != null, "column should not be null"); if (!CanUserSortColumns || !sortColumn.CanUserSort) { return; } if (CommitAnyEdit()) { PrepareForSort(sortColumn); DataGridSortingEventArgs eventArgs = new DataGridSortingEventArgs(sortColumn); OnSorting(eventArgs); if (Items.NeedsRefresh) { try { Items.Refresh(); } catch (InvalidOperationException invalidOperationException) { Items.SortDescriptions.Clear(); throw new InvalidOperationException(SR.Get(SRID.DataGrid_ProbableInvalidSortDescription), invalidOperationException); } } } }
/// <summary> /// Intercepts the OnSort event and performs a custom sort on Graphic.Attributes /// </summary> protected override void OnSorting(DataGridSortingEventArgs e) { base.OnSorting(e); }