Use the UltraGrid's BeforeSortChange and AfterSortChange events
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The UltraGrid fires both a BeforeSortChange and
an AfterSortChange event when the grid header is clicked
and the HeaderClickAction is set to one of the
sort options.
The UltraGrid default sort
processing is asynchronous. A drawback to asynchronous processing
is that the cursor does not automatically change to indicate ongoing
processing. To provide the end-user with that visual clue, you can
switch to synchronous processing and change the cursor by including
code like the following in the BeforeSortChange event:
|
You would then set the cursor back to default
in the AfterSortChange event as follows:
|
Setting the HeaderClickAction to ExternalSortSingle or ExternalSortMulti tells
the UltraGrid not to do its own sorting. To give
access to the sort specified in the UI, the UltraGrid exposes
a SortColumns collection on the band. Because this
is a collection, you can sort on multiple columns when you specify
the ExternalSortMulti option. This collection contains UltraGridColumns that
expose a SortIndicator, which reflects the direction
of the sort in the UI. The SortColumns are updated
in the event, not before the event. So, you implement the ABL sort
in the AfterSortChange event to access the SortColumns that
correspond to the fired event.
The following code snippet
shows an example function that returns a sort string from a band
using the band's SortedColumns collection and the
sorted columns' SortIndicator. An AfterSortChange event
can call this function with the band attribute on the passed BandEventArgs as
input and append the returned string to the query of the grid's
data source before reopening the query:
|