Jump to content


Photo

Sort arrow invisible


  • Please log in to reply
4 replies to this topic

#1 Marc

Marc
  • Members
  • 62 posts

Posted 25 March 2007 - 04:48 PM

On NextDBGrid (and probably on NextGrid too), title sort arrows are not visible in most cases.

I have modified "NxCustomGridControl" like this to have sort arrow near caption :

CODE
procedure TNxCustomGridControl.PaintReportParts;

...

if Column.Sorted then
  begin
    ArrowPos.Y := R.Top + (R.Bottom - R.Top) div 2 - siSortArrowHeight div 2 - 1;
    //ArrowPos.X := TextPos.X + CaptionWidth + spArrowDistance;
    ArrowPos.X := TextPos.X + CaptionWidth;    // <--- replace previous line
    if (ArrowPos.X + siSortArrowWidth < R.Right) and
      not(sdaCustomArrow in StyleDisplayAttributes) then
        DrawArrow(ArrowPos.X, ArrowPos.Y, Column.SortKind = skAscending);
  end;

...


What is "spArrowDistance" ?

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 25 March 2007 - 04:52 PM

Hello Marc,

This is made by design (I was try to mimic Outlook 2003 appearance where arrow dissapear when there is a not much space to display it).

You may modify this constant to specify distance between text and arrow.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Peppa

Peppa
  • Members
  • 2 posts

Posted 12 April 2007 - 11:59 AM

Hi!

Drawing a sort sign on the right side of the column when text is too long is better choice, then not drawing a sort sign, I think. This way the available space for title text is calculated by reserving space for sort sign if the column is sorted. If there's enough space, there are't any changes in appearance, but if there isn't, the text may be cropped in some way (ellipsis for example) and the sort sign still stay visible at the right side of column.

If you have capacity, think about this solution, please.

regards

#4 yeohray

yeohray
  • Members
  • 24 posts

Posted 05 June 2007 - 01:39 PM

This issue was also bugging me, together with the one where the column header text was splling over into other columns if the header was centred or right aligned. Here are some code suggestions that:
    - draws a sort arrow everytime, so that if there is not enough space to display both header text and sort arrow, the header text is truncated, and the sort arrow is drawn on the far right
    - addresses the text spilling issue

Note that it does not address the case where a glyph is displayed in the column header (I haven't had the need to use that yet). All changes in the TStyleDisplay.DrawHeaderContent method, enclosed in // mod blocks:

CODE
procedure TStyleDisplay.DrawHeaderContent(Column: TNxCustomColumn; R: TRect);
var
   ...
//  start mod
  TextRectRight: Integer;
//  end mod
begin
  with Canvas, Column.Header do
  begin
//  start mod
    TextRectRight := R.Right;
//  end mod

    ...
    if not(Glyph.Empty or (DisplayMode = dmTextOnly)) then { show glyph }
    begin
    ...
    end else
    begin
      case Alignment of
        taLeftJustify:
        begin
          TextPos.X := R.Left + spHeaderMargin;

//  start mod
          if Column.Sorted then
          begin
            Dec(TextRectRight, siSortArrowWidth + spArrowDistance + spHeaderMargin);
            if (TextRectRight - TextPos.X) < CaptionWidth then
            begin
              TextRectRight := R.Right - siSortArrowWidth - spHeaderMargin;
            end;

            if TextRectRight < (TextPos.X) then
              TextRectRight := TextPos.X;
          end;
//  end mod

        end;

        taRightJustify:
        begin
//  start mod
          TextPos.X := R.Left + spHeaderMargin;
          if CaptionWidth < (Column.Width - spHeaderMargin) then
            TextPos.X := R.Right - CaptionWidth;

          if Column.Sorted then
          begin
            Dec(TextPos.X, (siSortArrowWidth + spArrowDistance + spHeaderMargin));
            if TextPos.X < (R.Left + spHeaderMargin) then
            begin
              TextPos.X := R.Left + spHeaderMargin;
              Dec(TextRectRight, siSortArrowWidth + spHeaderMargin);
            end;
          end;
//  end mod
        end;

        taCenter:
        begin
          TextPos.X := R.Left + (R.Right - R.Left) div 2 - CaptionWidth div 2;

//  start mod
          if TextPos.X < (R.Left + spHeaderMargin) then
            TextPos.X := R.Left + spHeaderMargin;

          if Column.Sorted then
          begin
            if (TextPos.X + CaptionWidth + siSortArrowWidth + spHeaderMargin) > R.Right then
            begin
              TextRectRight := R.Right - siSortArrowWidth - spHeaderMargin;
            end;
          end;
//  end mod

        end;
      end;
    end;
    if DisplayMode <> dmImageOnly then { show text }
    begin
//    start mod
      CaptionRect := Rect(TextPos.X, R.Top, TextRectRight, R.Bottom);
//    end mod

  ...

  if Column.Sorted then
  begin
    ...
//  start mod
    if (ArrowPos.X + siSortArrowWidth) > R.Right then
    begin
      if (R.Right - siSortArrowWidth - spHeaderMargin) > TextPos.X then
        ArrowPos.X := R.Right - siSortArrowWidth - spHeaderMargin;
    end;
//  end mod

  ...
end;


#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 05 June 2007 - 02:05 PM

Hello Yeohray,

I was add in latest relase one new property HideArrow in Column.Header. If is set to False, this tell that sort arrow will not be hidden if column is shrinked.

regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users