Class SortColumnDescriptor
A SortColumnDescriptor defines the sort order or grouping of a table. SortColumnDescriptors are managed by the SortColumnDescriptorCollection which is returned by the SortedColumns or GroupedColumns property of a TableDescriptor.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Grouping
Assembly: Syncfusion.Grouping.Base.dll
Syntax
public class SortColumnDescriptor : DescriptorBase, ICustomTypeDescriptor, IDisposable, ICloneable, IStandardValuesProvider
Constructors
SortColumnDescriptor()
Initializes a new instance of SortColumnDescriptor class.
Declaration
public SortColumnDescriptor()
SortColumnDescriptor(String)
Initializes a new instance for SortColumnDescriptor class with the given name.
Declaration
public SortColumnDescriptor(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The field name. |
SortColumnDescriptor(String, ListSortDirection)
Initializes a new instance for SortColumnDescriptor class. with the given name.
Declaration
public SortColumnDescriptor(string name, ListSortDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The field name. |
System.ComponentModel.ListSortDirection | sortDirection | The sort direction. |
Properties
Categorizer
Gets or sets a custom categorizer for categorizing records in the table.
Declaration
public IGroupByColumnCategorizer Categorizer { get; set; }
Property Value
Type |
---|
IGroupByColumnCategorizer |
Collection
Gets the collection this descriptor belongs to.
Declaration
public SortColumnDescriptorCollection Collection { get; }
Property Value
Type |
---|
SortColumnDescriptorCollection |
Comparer
Gets or sets a custom comparer for sorting records in the table.
Declaration
public IComparer Comparer { get; set; }
Property Value
Type |
---|
System.Collections.IComparer |
FieldDescriptor
Gets the FieldDescriptor in the parent table.
Declaration
public FieldDescriptor FieldDescriptor { get; }
Property Value
Type |
---|
FieldDescriptor |
GroupSortOrderComparer
Gets or sets a custom comparer for sorting groups if groups should be sorted in a different order than the category, e.g. sort by summary values of nested groups.
Declaration
public IGroupSortOrderComparer GroupSortOrderComparer { get; set; }
Property Value
Type |
---|
IGroupSortOrderComparer |
Examples
This example shows how to customize sorting of groups that were categorized based on ShipVia field. The groups will be sorted by the value of a summary in the group.
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Clear();
SortColumnDescriptor gsd = new SortColumnDescriptor("ShipCountry");
gsd.GroupSortOrderComparer = new ShipViaComparer(summaryColumn1.GetSummaryDescriptorName(), "Average");
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(gsd);
this.gridGroupingControl1.InvalidateAllWhenListChanged = true;
public class ShipViaComparer : object, IGroupSortOrderComparer
{
string summaryDescriptorName;
string propertyName;
public ShipViaComparer(string summaryDescriptorName, string propertyName)
{
this.summaryDescriptorName = summaryDescriptorName;
this.propertyName = propertyName;
}
#region IComparer Members
public int Compare(object x, object y)
{
Group gx = (Group) x;
Group gy = (Group) y;
bool strongTyped = true;
if (strongTyped)
{
// strong typed (propertyName is ignored ...)
DoubleAggregateSummary dasx = (DoubleAggregateSummary) gx.GetSummary(summaryDescriptorName);
DoubleAggregateSummary dasy = (DoubleAggregateSummary) gy.GetSummary(summaryDescriptorName);
int v = dasx.Average.CompareTo(dasy.Average);
// Console.WriteLine("Compare {0} to {1}: {2}", dasx.Average, dasy.Average, v);
return v;
}
else
{
// using reflection (slower but more flexible using propertyName)
object vx = gx.GetSummaryProperty(summaryDescriptorName, propertyName);
object vy = gy.GetSummaryProperty(summaryDescriptorName, propertyName);
return ((IComparable) vx).CompareTo(vy);
}
}
#endregion
public string[] GetDependantFields(TableDescriptor td)
{
SummaryDescriptor sd = td.Summaries[summaryDescriptorName];
if (sd == null)
return new string[0];
return new string[] { sd.MappingName };
}
}
IsSorting
For internal use.
Declaration
public bool IsSorting { get; set; }
Property Value
Type |
---|
System.Boolean |
Name
The name of the field to sort. Usually the same as the corresponding GridColumnDescriptor.MappingName or FieldDescriptor.Name.
Declaration
public virtual string Name { get; set; }
Property Value
Type |
---|
System.String |
SortDirection
Gets or sets the sort direction.
Declaration
public ListSortDirection SortDirection { get; set; }
Property Value
Type |
---|
System.ComponentModel.ListSortDirection |
TableDescriptor
The TableDescriptor that this descriptor belongs to.
Declaration
public TableDescriptor TableDescriptor { get; }
Property Value
Type |
---|
TableDescriptor |
Methods
Clone()
Creates a copy of this descriptor.
Declaration
public SortColumnDescriptor Clone()
Returns
Type | Description |
---|---|
SortColumnDescriptor | A copy of this descriptor. |
CopyAllMembersTo(SortColumnDescriptor)
Copies all members to another object without raising change events.
Declaration
protected void CopyAllMembersTo(SortColumnDescriptor sd)
Parameters
Type | Name | Description |
---|---|---|
SortColumnDescriptor | sd | The target object. |
Dispose(Boolean)
Releases all resources used by the System.ComponentModel.Component.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true To release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
Remarks
See the documentation for the System.ComponentModel.Component class and its Dispose member.
Equals(Object)
Determines if the specified object and current object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | An object to compare. |
Returns
Type | Description |
---|---|
System.Boolean | True if the objects are equal; False otherwise. |
Overrides
GetHashCode()
Serves as a hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | Hash code. |
Overrides
GetName()
Gets the name of the descriptor.
Declaration
public override string GetName()
Returns
Type | Description |
---|---|
System.String | Descriptor name. |
Overrides
InitFieldDescriptor(TableDescriptor)
Called internally to initialize field descriptor for the Name of the field.
Declaration
public virtual bool InitFieldDescriptor(TableDescriptor tableDescriptor)
Parameters
Type | Name | Description |
---|---|---|
TableDescriptor | tableDescriptor | The table descriptor for the field. |
Returns
Type | Description |
---|---|
System.Boolean | True if field descriptor was found; False otherwise. |
InitializeFrom(SortColumnDescriptor)
Initializes this object and copies properties from another object. PropertyChanging and PropertyChanged events are raised for every property that is modified. If both objects are equal, no events are raised.
Declaration
public virtual void InitializeFrom(SortColumnDescriptor other)
Parameters
Type | Name | Description |
---|---|---|
SortColumnDescriptor | other | The source object. |
OnPropertyChanged(DescriptorPropertyChangedEventArgs)
Raises the PropertyChanged event.
Declaration
protected virtual void OnPropertyChanged(DescriptorPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DescriptorPropertyChangedEventArgs | e | A DescriptorPropertyChangedEventArgs that contains the event data. |
OnPropertyChanging(DescriptorPropertyChangedEventArgs)
Raises the PropertyChanging event.
Declaration
protected virtual void OnPropertyChanging(DescriptorPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
DescriptorPropertyChangedEventArgs | e | A DescriptorPropertyChangedEventArgs that contains the event data. |
SetGroupSummarySortOrder(String, String)
Sets a custom comparer for sorting groups if groups should be sorted in a different order than the category, e.g. sort by summary values of nested groups.
Declaration
public void SetGroupSummarySortOrder(string summaryDescriptorName, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | summaryDescriptorName | Name of the summary descriptor. |
System.String | propertyName | Summary function. |
Examples
This example shows how to customize sorting of groups that were categorized based on ShipVia field. The groups will be sorted by the value of a summary in the group.
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Clear();
SortColumnDescriptor gsd = new SortColumnDescriptor("ShipCountry");
gsd.SetGroupSummarySortOrder(summaryColumn1.GetSummaryDescriptorName(), "Average", ListSortDirection.Ascending);
this.gridGroupingControl1.InvalidateAllWhenListChanged = true;
SetGroupSummarySortOrder(String, String, ListSortDirection)
Sets a custom comparer for sorting groups if groups should be sorted in a different order than the category, e.g. sort by summary values of nested groups.
Declaration
public void SetGroupSummarySortOrder(string summaryDescriptorName, string propertyName, ListSortDirection sortDirection)
Parameters
Type | Name | Description |
---|---|---|
System.String | summaryDescriptorName | Name of the summary descriptor. |
System.String | propertyName | Summary function. |
System.ComponentModel.ListSortDirection | sortDirection | Sort order. |
Examples
This example shows how to customize sorting of groups that were categorized based on ShipVia field. The groups will be sorted by the value of a summary in the group.
this.gridGroupingControl1.TableDescriptor.GroupedColumns.Clear();
SortColumnDescriptor gsd = new SortColumnDescriptor("ShipCountry");
gsd.SetGroupSummarySortOrder(summaryColumn1.GetSummaryDescriptorName(), "Average", ListSortDirection.Ascending);
this.gridGroupingControl1.InvalidateAllWhenListChanged = true;
ToString()
Returns a string holding the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String representation of the current object. |
Overrides
Events
PropertyChanged
Occurs when a property was changed.
Declaration
public event DescriptorPropertyChangedEventHandler PropertyChanged
Event Type
Type |
---|
DescriptorPropertyChangedEventHandler |
PropertyChanging
Occurs before a property is changed.
Declaration
public event DescriptorPropertyChangedEventHandler PropertyChanging
Event Type
Type |
---|
DescriptorPropertyChangedEventHandler |
Explicit Interface Implementations
IStandardValuesProvider.GetStandardValues(PropertyDescriptor)
Returns an array of standard values used by StandardValuesCollectionConverter.
Declaration
ICollection IStandardValuesProvider.GetStandardValues(PropertyDescriptor pd)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.PropertyDescriptor | pd | An instance of the System.ComponentModel.PropertyDescriptor class. |
Returns
Type | Description |
---|---|
System.Collections.ICollection | An array of standard values used by StandardValuesCollectionConverter. |
ICloneable.Clone()
Creates the clone of this object.
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
System.Object | Returns the copied collection. |