Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Managing data updates : Sorting : Using the SortRequest event
 
Using the SortRequest event
.NET UI controls that rely on their data source for sorting, like the System.Windows.Forms.DataGridView, publish the SortRequest event. The ProBindingSource publishes the SortRequest event when a user action causes the bound UI control to request a sort from the ProBindingSource. This event uses an OpenEdge built-in class, Progress.Data.SortRequestEventArgs, that extends the .NET System.EventArgs class to pass the event arguments. The event argument class contains the FieldIndex, FieldName, ArrayIndex, Ascending, and Sorted properties.
Note: Unlike the DataGridView, the UltraGrid does not publish this event.
An event handler for this event uses the following syntax:

Syntax

EventHandlerName
  (
     INPUT sender AS CLASS System.Object,
     INPUT args AS CLASS Progress.Data.SortRequestEventArgs
  ).
Where EventHandlerName is the name of the event handler, sender is the object reference to the ProBindingSource, and args is the object reference to the SortRequestEventArgs instance that contains the event arguments.
If the bound ABL data source object is a ProDataSet, this event always refers to the top-level query. If your application needs to sort the child records, one approach is to create two ProBindingSource objects, one for the parent and one for the child, and to display the child records for a specific parent record in another UI control.
When this event occurs, the event handler must use a modified sort criteria based on the values in the SortRequestEventArgs object to reopen the query associated with the ABL data source object. The FieldIndex, FieldName, and ArrayIndex properties indicate the field on which to sort the query. The Ascending property indicates the order of the sort, with the TRUE meaning an ascending sort and FALSE meaning a descending sort. The event handler should set the Sorted property to TRUE when the query reopens successfully with the new sort criteria.
The FieldIndex, FieldName, and ArrayIndex properties combine to indicate the new sort field. FieldName is the unqualified field name as specified in the ProBindingSource. Even if you had to qualify the field name in the constructor, the FieldName is unqualified in the SortRequestEventArgs class. FieldIndex is a 1-based index of the ProBindingSource fields in the order that they appear in the constructor's included field list. If the specified field is an array field, the ArrayIndex property indicates the proper element in the array with a 1-based index of the array elements.