CRDBGrid -> How to catch click on sort column before sort?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pmatos
Posts: 5
Joined: Tue 11 Jul 2006 18:00

CRDBGrid -> How to catch click on sort column before sort?

Post by pmatos » Fri 18 May 2007 16:36

Hi!

How can I catch the click on the title column on a CRDBGrid with sort enabled, before sort is executed, so I can , under certain rules, cancel the sort?

Thanks.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 21 May 2007 08:04

The TCRDBGrid component doesn't have such feature. But you can edit its source code to add this feature. For example, add to TCRDBGrid a new event:

Code: Select all

type
  TBeforeSort = procedure(Sender: TObject; Column: TColumn; var EnableSort: boolean) of object;
Then call this event handler from the MouseUp method of TCRDBGrid.

Code: Select all

...
          if TCRColumn(Column).CanBeSorted and (dgeEnableSort in OptionsEx)
            and MouseInLowerstLevel(X,Y,Column) and (LastBtn = Column.Index)
          then begin
            SortEnabled := True;
            if Assigned(FBeforeSort) then
              FBeforeSort(Self, Column, SortEnabled);
            if SortEnabled then begin
...

pmatos
Posts: 5
Joined: Tue 11 Jul 2006 18:00

Post by pmatos » Mon 21 May 2007 10:44

Do you have any plans to include such feature in a future version?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 21 May 2007 11:12

CRControls components are no longer supported by Core Lab. So we do not plan to add such feature to TCRDBGrid.

Post Reply