Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001588 [JEDI VCL] 00 JVCL Components major always 2004-04-06 03:10 2004-04-22 23:52
Reporter anonymous View Status public  
Assigned To user72
Priority normal Resolution fixed  
Status resolved   Product Version
Summary 0001588: Bug FixedCols in TjbDBGrid
Description When the FixedCols property has a value and prick in a cell that is not fixed with the mouse, not edit the value of the cell

I am making the proof in a grid with four columns of those which the two first columns are fixed
Additional Information Cuando la propiedad fixedcols tiene un valor y pinchas en una celda que no es fija con el ratón, no deja editar el valor de la celda

Estoy haciendo la prueba en un grid con cuatro columnas de las cuales las dos primeras son fijas
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0003700)
user72
2004-04-07 13:24

Do you have RowSelect set to true?
(0003703)
user72
2004-04-07 14:44

I see it here as well when trying to select a row > 1. Can't seem to find the reason, though... Any thoughts?
(0003837)
user72
2004-04-14 04:39
edited on: 2004-04-14 04:40

Suggested by Flemming Brandt Clausen (changes in bold):

procedure TJvDBGrid.DoAutoSizeColumns;
var
  TotalWidth, OrigWidth: Integer;
  I: Integer;
  ScaleFactor: double;
  AWidth, AUsedWidth, ALeftCol: Integer;
begin
  if not AutoSizeColumns or FInAutoSize or (Columns.Count = 0) or (FGridState = gsColSizing) then
    Exit;
  FInAutoSize := True;
  ALeftCol := LeftCol;
  try
    // get useable width
    TotalWidth := ClientWidth - (Ord(dgIndicator in Options) * IndicatorWidth) - (Ord(dgColLines in Options) *
      Columns.Count * GridLineWidth);
    OrigWidth := 0;
    // get width currently occupied by columns
if FixedCols = 0 then
      BeginLayout;
    try
      // autosize all columns proportionally
      if AutoSizeColumnIndex = -1 then
      begin
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible then
            Inc(OrigWidth, Columns[I].Width);
        if OrigWidth = 0 then
          OrigWidth := 1;
        // calculate the realtionship between what's available and what's in use
        ScaleFactor := TotalWidth / OrigWidth;
        if ScaleFactor = 1.0 then
          Exit; // no need to continue - resizing won't change anything
        AUsedWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible then
          begin
            if I = LastVisibleColumn then
              Columns[I].Width := TotalWidth - AUsedWidth
            else
            begin
              AWidth := GetMaxColWidth(GetMinColWidth(round(ScaleFactor * Columns[I].Width)));
              if AWidth < 1 then
                AWidth := 1;
              Columns[I].Width := AWidth;
              Inc(AUsedWidth, AWidth);
            end;
          end;
      end
      // a index of -2 indicates that we want to autosize the last visible column
      else if AutoSizeColumnIndex = -2 then // auto size last visible
      begin
        // reuse AUsedWidth as the actual resize column index
        AUsedWidth := LastVisibleColumn;
        if AUsedWidth < 0 then
          Exit;
        OrigWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible and (I <> AUsedWidth) then
            Inc(OrigWidth, Columns[I].Width);
        AWidth := GetMaxColWidth(GetMinColWidth(TotalWidth - OrigWidth));
        if AWidth > 0 then
          Columns[AUsedWidth].Width := AWidth;
      end
      // only auto size one column
      else if AutoSizeColumnIndex <= LastVisibleColumn then
      begin
        OrigWidth := 0;
        for I := 0 to Columns.Count - 1 do
          if Columns[I].Visible and (I <> AutoSizeColumnIndex) then
            Inc(OrigWidth, Columns[I].Width);
        AWidth := GetMaxColWidth(GetMinColWidth(TotalWidth - OrigWidth));
        if AWidth > 0 then
          Columns[AutoSizeColumnIndex].Width := AWidth;
      end;
    finally
if FixedCols = 0 then
        EndLayout;
    end;
  finally
    FInAutoSize := False;
    LeftCol := ALeftCol;
  end;
end;

Does this resolve your issue?

edited on: 04-14-04 04:40
(0003846)
fbc (reporter)
2004-04-14 05:38

After thinking a bit, I find this to be a better solution.
I can't see any reason for calling DoAutoSize on mouseup, unless there has been a column resize, and in that case Cell.Y has to be zero.
And doing it this way, will leave BeginLayout/Endlayout active, as it should be, if one have to belive the help-text.

Procedure MouseUp .....
....
....
 inherited MouseUp(Button, Shift, X, Y);
  //Add this line --
  if Cell.Y = 0 then
    DoAutoSizeColumns;
end;
(0003859)
user72
2004-04-14 11:35

Please try fbc's latest suggestion and let us know how it works for you.
(0003871)
xerkan (reporter)
2004-04-15 02:55

The modification done for fbc works but has two side effects:

* When several records are had and you go away to the last column of the last record, the fixed columns put themselves of white color, and the autosize stops working correctly since you make a column bigger can eliminate the last one
(0003877)
user72
2004-04-15 10:01

I am not sure I understand the problem but I am unable to duplicate it (making the FixedCols draw white, autosize stops working). Have you removed the first fix and do you have the latest JvDBGrid (v 1.45 2004/04/02)?

If yes, could you provide a step by step description to duplicate the problem?

Also, attach the relevant dfm values for the grid.
(0004024)
user72
2004-04-22 23:52

Since no reply, I assume it works. Post again if that is not the case.

- Issue History
Date Modified Username Field Change
2004-04-06 03:10 anonymous New Issue
2004-04-07 13:24 user72 Note Added: 0003700
2004-04-07 13:24 user72 Status new => assigned
2004-04-07 13:24 user72 Assigned To => user72
2004-04-07 14:44 user72 Note Added: 0003703
2004-04-14 04:39 user72 Note Added: 0003837
2004-04-14 04:40 user72 Note Edited: 0003837
2004-04-14 04:41 user72 Status assigned => feedback
2004-04-14 05:38 fbc Note Added: 0003846
2004-04-14 11:35 user72 Note Added: 0003859
2004-04-15 02:55 xerkan Note Added: 0003871
2004-04-15 10:01 user72 Note Added: 0003877
2004-04-22 23:52 user72 Status feedback => resolved
2004-04-22 23:52 user72 Resolution open => fixed
2004-04-22 23:52 user72 Note Added: 0004024


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker