probindingsource SortRequest Event

Posted by Roger Blanchard on 12-Feb-2009 06:36

Does anyone know if this should fire? I have a form with an UltraGrid and when I click on the column to sort the records the sort events fire in the UltraGrid but not in the probindingsource. I have AutoSort set = TRUE and have tried different settings in the UltraGrid:DisplayLayout:Override:HeaderClickAction to see if that makes any difference.

The docs say:

AutoSort - Indicates whether the ProBindingSource object automatically resorts records in the ABL data source object in response to appropriate user actions in the bound .NET control. The default value is FALSE.

When bound to a ProDataSet object, this property applies only to the top-level table displayed in the .NET control.

Sort Request - Published when some user action initiates a sort operation

(for example, clicking on a column header in a grid control).

Where would the best place be to add our own sorting logic?

ultraGrid1_BeforeSortChange

ultraGrid1_AfterSortChange

bindingSource1_SortRequest

Any help would be appreciated.

All Replies

Posted by Admin on 12-Feb-2009 06:41

The SortRequest only fires for simple grids (like the MS DataGridView).

BeforeSortChange gives you a chance to query the sorted columns/bands (so, what the user actually clicked at) and cancel the event by setting e:Cancel = True.

That gives you a chance to reopen the query (manually) with the correct DB sort condition.

At the AfterSortChange it's actually already happened. That might be a place to query the sort order and store that in the users profile.

Posted by Roger Blanchard on 12-Feb-2009 07:44

Thanks Mike...very helpful. I have manual sorting working in the BeforeSortChange and wanted to verufy this is where it should be done.

As always THANK YOU!!

Posted by Håvard Danielsen on 16-Feb-2009 12:15

Just for the record... it is fully possible to do the manual sort in the AfterSortChange event as long as you set the HeaderClickAction to ExternalSortSingle or ExternalSortMultiple, which suppresses the default sort.

Setting cancel to true in the BeforeSortChange will then prevent the AfterSortChange from firing.

This way you work with the grid and use the cancel for what it was meant for.

There is really nothing wrong in doing it in BeforeSortChanged, as long as you do not ignore the HeaderClickAction and use cancel= true as a way to prevent the default sort after you've done the manual sort.

This thread is closed