Ticket AQ16058
Visible to All Users

Sorting by other field (when clicking header) in ExpressGrid 6

created 18 years ago

Hi,
I got this code from you for drawing the header yourself in ExpressGrid 5 and this seems necessary still in the new ExpressGrid 6 (if you want to sort by another field than the one shown in the grid). This old code does not show the new header highlighting correctly though. Do you have some new code for this?
Here is the old code:
procedure TViewManager_frm.grid_ViewEntryDBBandedTableView1TitleCustomDrawHeader(
  Sender: TcxGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
var
  I: Integer;
  R: TRect;
begin
  with AViewInfo do
  begin
    Sender.Painter.LookAndFeelPainter.DrawHeader(ACanvas, Bounds, TextAreaBounds,
    Neighbors, Borders, cxbsNormal, taLeftJustify, vaTop, False, False, Column.Caption, ACanvas.Font, clNone, Color);
    with TcxGridColumnHeaderViewInfoAccess(AViewinfo) do
      for I := 0 to AreaViewInfoCount - 1 do
      begin
        if AreaViewInfos[I] is TcxGridColumnHeaderFilterButtonViewInfo then
           Sender.Painter.LookAndFeelPainter.DrawFilterDropDownButton(Canvas, AreaViewInfos[I].Bounds,
           GridCellStateToButtonState(AreaViewInfos[I].State), TcxGridColumnHeaderFilterButtonViewInfo(AreaViewInfos[I]).Active);
        R := AreaViewInfos[I].Bounds;
        R.Right := AreaViewInfos[I].Bounds.Left - 2;
        R.Left := R.Right - Sender.Painter.LookAndFeelPainter.SortingMarkSize.X;
        R.Bottom := R.Bottom - 4;
        R.Top := R.Top + 4;
      end;
    if grid_ViewEntryDBBandedTableView1TitleSort.SortOrder <> soNone then
    begin
      ACanvas.Brush.Color := AViewInfo.Params.Color;
      InflateRect(R, 1, 1);
      ACanvas.FillRect®;
      InflateRect(R, -1, -1);
      Sender.Painter.LookAndFeelPainter.DrawSortingMark(ACanvas, R, grid_ViewEntryDBBandedTableView1TitleSort.SortOrder = soAscending);
    end;
    ADone := True;
  end;
end;

Best Regards,
Johan

Show previous comments (2)
DevExpress Support Team 18 years ago

    Hi,
    This gives the same result as my old code. The sort works but the header is
    not drawn correctly. There are two problems:

    1. When the mouse-pointer is over the columns that got the CustomDrawHeader
      event; they are not highlighted correctly when the LookAndFeel.NativeStyle
      property is set to true.
    2. The sorting mark that is drawn is not transparent and therfor looks very
      ugly and out of place.
      Do you have some revised code where at least the first problem is resolved?
      Thanks!
      Best Regards,
      Johan
    DevExpress Support Team 18 years ago

      Hi Johan,
      Thank you for the detailed description of the problem.
      Attached is the modified sample project, which seems to process these situations correctly. Please review it and let us know your results.
      BTW, this task also can be accomplished by handling the OnCompare event. Please refer to the "How to sort a column by the values in another (hidden) column?" report (www.devexpress.com/issue=CQ58532) to find more information on this subject.
      Thanks,
      Vito

        Thanks Vito that fixed it.
        I can't try the OnCompare alternative though since the Delphi 7 helpfiles and Vista is no good combination :) Can you copy and send the example and helptext?
        -- Johan

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.