Jump to content


Photo

Serious bug in TNextGrid with TNxTreeColumn, I'm really disppointed now for NextGrid now!


  • Please log in to reply
8 replies to this topic

#1 WEI

WEI
  • Members
  • 11 posts

Posted 27 November 2006 - 09:59 PM

Hi, Boki

I guess you have a serious bug in TNextGrid with TNxTreeColumn when using PAGEDOWN and PAGEUP button, here is how to reproduce it:

Create a clean form, add a NextGrid control (make the visible row count = 10 rows) and with one TNxTreeColumn and one TNxTextColumn, add a button on the form, at the on button click event, adding the following code

CODE
  nxgrid.AddRow(20);
  nxgrid.AddChildRow(0);
  nxgrid.AddChildRow(0);


When if the first row is expanded, Press PAGEDOWN button will goes to 10th row, which is good. but when the first row is shrink(all its child rows are all invisible), then press PAGEDOWN, it will goes to/8th rows. so if adding more child rows, press PAGEDOWN will goes to row of VISIBLECOUNT - child count of first row. so you can image if the child row of the first row exceed the total of visible row count, What will be happend?

so I would assume that pressing UP ARROW and DOWN ARROW would have the same problem.

so please give this a quick fix, we can not afford this kind of bug to give to our customers.

Why don't you fully test your grid before make a new release?

Regards,

WEI

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 November 2006 - 10:37 PM

Hello Wei,

I will fix it. Durring time, NextGrid has become more complex and ufortunatelly, there are allways hidden bugs.

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 WEI

WEI
  • Members
  • 11 posts

Posted 28 November 2006 - 03:36 AM

QUOTE (Boki (Berg) @ Nov 27 2006, 04:37 PM) <{POST_SNAPBACK}>
Hello Wei,

I will fix it. Durring time, NextGrid has become more complex and ufortunatelly, there are allways hidden bugs.

regards


Hi, Boki

Here is my thought probably can solve the problem:

Step1:

Get ride of GetRowVisible function.

Step2:

CODE
  function TNextGrid.GetRowCount: Integer;
  begin
     Result := FCells.VisibleRowCount; // <-- NOT FCells.RowCount
  end;


Step3, Add a new function in the TNextCustomGridControl

CODE
  TNextCustomGridControl.GetAbsoluteRow(ARow: Integer): Integer; virtual;
  begin
     Result := ARow;
  end;


Step 4, Change GetSelectedRow to:

CODE
  function TNextCustomGridControl.GetSelectedRow: Integer;
  begin
     Result := GetAbsoluteRow(FSelectedRow);
  end;



Step 5, In the DrawCell method, change to pass Row parameter with GetAbsoluteRow(Row) to all DoXXXXXX methods. To get the cells display text in the DrawCell method, you can calls :

CODE
   AText := Cells[ACol, GetAbsoluteRow(ARow];


Step 6, override TNextGrid.GetAbsoluteRow(ARow: Integer): Integer;
CODE
  function TNextGrid.GetAbsoluteRow(ARow: Integer): Integer;
  begin
      if FCells.Row[ARow].Visible then
        Result := ARow
      else
      begin
         Result := 0;
         while ARow >= 0 do
         begin
         if FCells.Row[Result].Visible then
         begin
            Dec(ARow);
            if ARow < 0 then Exit;
         end;
         Inc(Result);
      end; { while }
  end;


Hope, these may help you.

Regards,

WEI

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 28 November 2006 - 05:34 AM

Hello WEI,

I will try your code, but I have already start working on it.

Thank you anyway and please sorry for this problem.

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.

#5 WEI

WEI
  • Members
  • 11 posts

Posted 07 December 2006 - 04:23 PM

QUOTE (Boki (Berg) @ Nov 27 2006, 11:34 PM) <{POST_SNAPBACK}>
Hello WEI,

I will try your code, but I have already start working on it.

Thank you anyway and please sorry for this problem.

regards


Hi, Boki

Does the latest version 3.9.6 include this fix?

WEI

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 December 2006 - 04:54 PM

Hello WEI,

I have add fix on other place, please try to copy this procedure:

CODE
procedure TNxCustomGridControl.MoveSelectionDown(Shift: TShiftState);
var
  I, R: Integer;
begin
  R := -1;
  if InputSelected then
  begin
    InputSelected := False;
    if GetRowCount > 0 then R := 0;
  end else
  begin
    R := -1;
    if SelectedRow >= Pred(RowCount) then Exit;
    for I := SelectedRow + 1 to GetRowCount - 1 do
      if (GetRowVisible(I)) and (I <> SelectedRow) then begin
        R := I;
        Break;
      end;
  end;
  if R = -1 then Exit; // <-- new line
  SelectCell(SelectedColumn, R, Shift);
  if GridStyle = gsReport then
  begin
    if GetCellRect(SelectedColumn, SelectedRow).Bottom >= GetBodyRect.Bottom
      then VertScrollBar.Next;
  end else
    if GetSlideRect(SelectedRow).Bottom >= ClientHeight
      then VertScrollBar.Next;
end;


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.

#7 WEI

WEI
  • Members
  • 11 posts

Posted 07 December 2006 - 05:44 PM

QUOTE (Boki (Berg) @ Dec 7 2006, 10:54 AM) <{POST_SNAPBACK}>
Hello WEI,

I have add fix on other place, please try to copy this procedure:

CODE
procedure TNxCustomGridControl.MoveSelectionDown(Shift: TShiftState);
var
  I, R: Integer;
begin
  R := -1;
  if InputSelected then
  begin
    InputSelected := False;
    if GetRowCount > 0 then R := 0;
  end else
  begin
    R := -1;
    if SelectedRow >= Pred(RowCount) then Exit;
    for I := SelectedRow + 1 to GetRowCount - 1 do
      if (GetRowVisible(I)) and (I <> SelectedRow) then begin
        R := I;
        Break;
      end;
  end;
  if R = -1 then Exit; // <-- new line
  SelectCell(SelectedColumn, R, Shift);
  if GridStyle = gsReport then
  begin
    if GetCellRect(SelectedColumn, SelectedRow).Bottom >= GetBodyRect.Bottom
      then VertScrollBar.Next;
  end else
    if GetSlideRect(SelectedRow).Bottom >= ClientHeight
      then VertScrollBar.Next;
end;


regards


NO!. That doesn't help, it is NOT working. Did you really get what I was talking?

WEI

#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 07 December 2006 - 05:48 PM

Hello WEI,

This was the similar bug, I didn't completelly understand it. I will definitelly try your code.

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.

#9 WEI

WEI
  • Members
  • 11 posts

Posted 07 December 2006 - 08:14 PM

QUOTE (Boki (Berg) @ Dec 7 2006, 11:48 AM) <{POST_SNAPBACK}>
Hello WEI,

This was the similar bug, I didn't completelly understand it. I will definitelly try your code.

regards


OK. Here you go, let says, you have the total 20 rows of grid and its total visible rows = 10, and you're current highlighting the first row.

1) so press PAGEDOWN, the highlight bar (SelectedRow) should goes to 10th visible row.

2) now try to add 2/3 child rows to the first row of the grid. its still working when 1st row are expaned and SelectedRow = 0, when press PAGEDOWN, the highlight bar (SelectedRow) will goes from 1st row to 10th visible row.

3)now collaspe the 1st row of the grid, then press PAGEDOWN, what you can see that the highlight bar (SelectedRow) goes from 1st row to the 8th/7th visible row, which is wrong, it (SelectedRow) should still goes to 10th visible row.

4)If the total child rows I'm adding to 1st of row of the gird is 11, which >= the total 10 visible rows, collaspe the 1st row of the grid and press PAGEDOWN for example. the highlight bar will be disappeared.

the problem would be happend when pressing UP, DOWN, PAGEDOWN, PAGEUP when some of the rows are collaspe and some of rows are expanded.

This is the fundamental issue. if you can not solve it. I want to have my money back.

WEI




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users