Jump to content


Photo

NextGrid5 -> NextGrid6 upgrade


  • Please log in to reply
126 replies to this topic

#101 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 18 July 2018 - 11:08 AM

Attached File  NG5_V_Scroll_AllChildren.png   53.93KB   0 downloadsAttached File  NG6_NoVertScroll_MissingChildren_BlankChildren.png   56.87KB   0 downloadsThank you, Boki:

 

That seems to work.

I am further along with converting all this particular NG5 to NG6 grid and its routines. I am attaching a couple of screen shots to show you that something is not quite right with my NG6 converted grid:

 

(The screen shots are of the exact same grid state right after loading the underlying rows/nodes.)

 

1. I use a routine to load the grid from a database. The grid is a tree structure. After loading, I have been using a routine to collapse all child nodes recursively. I notice that you have a Collapse(Recursive) method. Both my routine and the Row.Collapse do not work for the NG6 grid

 

IF RecordCount > 0 THEN
    // when done colapse all child nodes
    // Starting with top row, top level
    begin
      // this doesn't work  to collapse, nor does CollapsAllChildren
      for j := 0 to Grid.RowCount do
      begin
        if Grid.RowExists(j) then
          Grid.Row[j].Collapse(True);
      end;
      Grid.Row[0].Selected := True;
      Grid.ScrollToSelected;
      // CollapseAllChildren6(0, 1, Grid) <== my routine which also does not collapse the NG6
    end;
 
2. There is no Vertical Scroll bar in the NG6, but is as expected in NG5. (I have both scroll bars properties set.)
3. I am not sure why (perhaps a difference in the use of Row, Child, Parent in NG6), but you can see that the tree structure is significantly different, for some nodes, it is loaded as a child and it should be a sibling, or just as perplexing, the node/row is present but there is no text.
 
Do you have any idea what is going on? This makes moving from NG5 to NG6 very difficult, since the functionality is so different.
 
Thank you,
Chuck


#102 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 24 July 2018 - 10:34 AM

Hi, Boki:

Any thoughts on my last post, above? Do you need more information from me. Code?

Thank you,

Chuck



#103 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 24 July 2018 - 09:19 PM

Hi,

I think I found where is the problem. I am working on it now. I will send you update in 2 days.

If you already have small demo project - it will help for sure at least for testing.
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.

#104 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 25 July 2018 - 05:21 PM

BelangerC mind sharing how you draw the nested (treed) grid?

 

I've been interested in doing this in the past but didn't have time to invest in figuring it out.

 

Also are you using TNextGrid or TNextDBGrid?

 

Thanks.



#105 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 25 July 2018 - 11:06 PM

Hi FourWhey,

Not sure if you are asking about tree lines. There is a (relatively new) ShowLines property in this column.
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.

#106 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 25 July 2018 - 11:33 PM

Hi, Boki:
Any thoughts on my last post, above? Do you need more information from me. Code?
Thank you,
Chuck


Hi,

I have just uploaded another update. You can use now:

Row[x].Collapse(True);

or Expand (also with recurse).

I will test it more in upcoming days, but I hope that this will help you.
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.

#107 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 26 July 2018 - 01:07 AM

Thank you, Boki!

 

I was starting to make a demo project for you but realized, that I do use Firebird and IBObjects to manage the data information. Not sure how I can make a demo for you or if let's say I load the grid from a text file whether that would represent the issues similarly. Any ideas on how to export the data and load a grid. Do you support CVS or something similar?

 

I will certainly try the update and see if it corrects the issues.

 

FourWhey: I am using TNextGrid to fill the grid. I query the data then use the query.RecordCount to AddRows(RecordCount), then iterate through the grid looking at changes to the parent Id to indicate adding a new tree branch. I have found TNextGrid easier to use in the long run than a DB grid. Depending on the grid and its use, I either use OnAfterEdit to save cell changes or Save any changes en mass by saving any cell/row changes all in one step.

 

Chuck



#108 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 26 July 2018 - 01:37 AM

Hi, Boki:

 

Yes, the test NG5 to NG6 conversion now properly collapses the tree. Thank you.

 

But, there is still the issue of no vertical scroll bar, even though property is set.

And the tree structure is off (meaning some nodes are now children when they should be siblings) and there are blank tree nodes.

 

Below is my code that I revised somewhat for the conversion. This routine fills the test NG6 grid:

 

PROCEDURE LoadGridTable6(Grid: TNextGrid6);
VAR
  RowParent, RowParentRow, i, j: INTEGER;
  ParentStrID: STRING;
  TableID: INTEGER;
 
BEGIN
 
  if Grid.Name = 'gridScanScope6' then
    TableID := 1;
 
 
  WITH ModData.qryAnyUse4 DO
  BEGIN
    SQL.Clear;
    SQL.Add('SELECT WIZ_TR_ID, w.ML_ID, Parent_ID, Wiz_Table_ID, Order_Index, ');
    SQL.Add(GetSQLDecrip('ml_item'));
    SQL.Add('from Wiz_Table_Rows w JOIN MasterLibrary ml ON ml.ML_ID = w.ml_id ');
    SQL.Add('where Wiz_Table_ID = :ID');
    SQL.Add('Order by Order_Index');
    Prepare;
    ParamByName('ID').AsInteger := TableID;
    Open;
    First;
 
    i := 0;
    j := 0;
 
    Grid.ClearRows;
 
    WHILE NOT eof DO
    BEGIN
      WITH Grid DO
      BEGIN
        IF FieldByName('Parent_ID').AsInteger = -1 THEN
        BEGIN
          AddRow(1);
          // if any children note the parent
          RowParent := FieldByName('ML_ID').AsInteger;
          RowParentRow := i;
          ParentStrID := 'NO PARENT ID';
        END
        ELSE IF FieldByName('Parent_ID').AsInteger > -1 THEN
        BEGIN
          ParentStrID := 'ML' + IntToStrZeroPad(FieldByName('Parent_ID')
            .AsInteger, 10);
 
          RowParentRow := GetParentRow6(ParentStrID, Grid);
 
          // AddChildRow(RowParentRow, crLast);
          AddChildRow(RowParentRow)
        END;
        // fill in all column information
        Cell[0, LastAddedRow].asString := FieldByName('ml_item').asString;
 
        // hidden row with info: RowID, either from ML or as User added row + ParentID + Original ID/
        Cell[Columns.Count - 1, LastAddedRow].asString :=
          'ML' + IntToStrZeroPad(FieldByName('Wiz_TR_ID').AsInteger, 10) + '|' +
          ParentStrID + '|NO CLONE ID_';
 
        // adjust row height based on added description
        // looks like you need this one that adds fudge factor to height, otherwise
        // some cells are too short
 
        GetBestFitRow6(LastAddedRow, 0, Grid);
 
      END; // with grid
      Next;
      Inc(i);
    END; // while not eof
    ModData.qryAnyUse4.Close;
 
    IF RecordCount > 0 THEN
    // when done colapse all child nodes
    // Starting with top row, top level
    begin
      // this doesn't work  to collapse, nor does CollapsAllChildren
      for j := 0 to Grid.RowCount do
      begin
        if Grid.RowExists(j) then
          Grid.Row[j].Collapse(True);
      end;
      //7/23/18 per Boki Row[x].Selected is more for multi-select, in any case
      //it does not actually make the row selected visually
     // Grid.Row[0].Selected := True;
      Grid.SelectedRow := 0;
      Grid.ScrollToSelected;
      // CollapseAllChildren6(0, 1, Grid)
    end;
  END; // with qryAnyUse3
 
END;


#109 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 26 July 2018 - 05:59 PM

Hi Chuck,

I'm unable to understand your code completely. But I can write you here few tips for using trees:

procedure TForm6.FormCreate(Sender: TObject);
var
  MyRow: INxRow;
begin
  // Add 4 root rows
  NextGrid61.AddRow(4);

  NextGrid61.AddChildRow(2); // Absolute index

  MyRow := NextGrid61.Row[3]; // Absolute index

  NextGrid61.AddChildRow(MyRow, 1);

  ShowMessage(IntToStr(MyRow.ParentRow.AbsoluteIndex));
end;

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.

#110 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 26 July 2018 - 06:34 PM

Hi FourWhey,

Not sure if you are asking about tree lines. There is a (relatively new) ShowLines property in this column.

 

Yes, the tree lines. So it draws the Parent/Child elements.



#111 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 26 July 2018 - 08:04 PM

Hi Fou

Yes, the tree lines. So it draws the Parent/Child elements.


You can use then ShowLines property of Column for this purpose.
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.

#112 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 26 July 2018 - 09:37 PM

Hi Fou
You can use then ShowLines property of Column for this purpose.

 

I guess I had an older version which is why I didn't have the option. I updated it and began experimenting.

 

I found that Parent rows do not participate in footer calculations.

Edit: It looks like they do participate, but the first row is always ignored even as the footer is updated when new rows are added. In the screenshot the footer calculation is set to SUM.

 

Is there a method similar to AddCells but for Child rows?

Attached Files



#113 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 July 2018 - 12:23 AM

Hm, weird bug. I will fix it now.
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.

#114 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 27 July 2018 - 09:29 AM

Thank you, Boki, for the suggested ways of handling tree row additions. I will have to look over my code and apply this. Apparently there is a functional difference between the same method name in both NG5 and NG6. The tree loading routine above properly loads a NG5 grid, but not NG6.

 

Do you have any thoughts about the lack of the vertical scroll bar?

Also, did you see my separate post about sliding the vertical scroll bar up causing an error message?

 

Chuck



#115 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 July 2018 - 03:41 PM

I guess I had an older version which is why I didn't have the option. I updated it and began experimenting.
 
I found that Parent rows do not participate in footer calculations.
Edit: It looks like they do participate, but the first row is always ignored even as the footer is updated when new rows are added. In the screenshot the footer calculation is set to SUM.
 
Is there a method similar to AddCells but for Child rows?


Can you please send me code of this mini demo you made. Here is a code which I used now for quick test and all seems to be calculated:

procedure TForm6.Button1Click(Sender: TObject);
begin
  NextGrid61.AddChildRow(1).Cells[0].AsInteger := 2;
  NextGrid61.AddChildRow(2).Cells[0].AsInteger := 3;
end;

procedure TForm6.FormCreate(Sender: TObject);
begin
  NextGrid61.AddCells(['10', '5', '15'], [0]);
end;

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.

#116 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 July 2018 - 03:43 PM

Thank you, Boki, for the suggested ways of handling tree row additions. I will have to look over my code and apply this. Apparently there is a functional difference between the same method name in both NG5 and NG6. The tree loading routine above properly loads a NG5 grid, but not NG6.
 
Do you have any thoughts about the lack of the vertical scroll bar?
Also, did you see my separate post about sliding the vertical scroll bar up causing an error message?
 
Chuck


I suspect that maybe RelativeIndex and AbsoluteIndex causes a problem in your code. 90% of the time is AbsoluteIndex, but if you adding row as ChildRow it's a RelativeIndex:

NextGrid61.Row[2].AddChildRow();
I will add documentation over methods so you can know where is AbsoluteIndex and where not.

I will also fix scrollbar problem.
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.

#117 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 27 July 2018 - 07:19 PM

Can you please send me code of this mini demo you made. Here is a code which I used now for quick test and all seems to be calculated:
 

procedure TForm6.Button1Click(Sender: TObject);
begin
  NextGrid61.AddChildRow(1).Cells[0].AsInteger := 2;
  NextGrid61.AddChildRow(2).Cells[0].AsInteger := 3;
end;

procedure TForm6.FormCreate(Sender: TObject);
begin
  NextGrid61.AddCells(['10', '5', '15'], [0]);
end;

 

Here you go. This was in Delphi 7.  Also, when a parent row is expanded and the child rows push the rows beneath it out of the viewable area of the grid, the vertical scrollbar does not appear as expected.

 

Here is a small gif showing the footer not calculating correctly and the scrollbar not appearing.

https://gfycat.com/V...dAsiandamselfly

 

It looks like TNxCustomGrid6... function SumCol iterates through the rows...

 

Here's what I found: If I add (1) Parent with (10) Children. The first time through, i == 0, Cell[Index, i].AsFloat == 0.

When a second row is added, the first row that's found with a value >0 is at index 0, and the row at index 11, which should have the second value i == 11, Cell[Index, i].AsFloat == 0.

 

Basically, the last row that's added is always 0 so the sum is always off by the value of whatever is in the most recently added row.

It's acting like TNxCustomGrid6.Recalculate is being called before the value in the last added (row) cell exists.

 

Thanks!

Attached Files



#118 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 July 2018 - 08:59 PM

Here you go. This was in Delphi 7.  Also, when a parent row is expanded and the child rows push the rows beneath it out of the viewable area of the grid, the vertical scrollbar does not appear as expected.
 
Here is a small gif showing the footer not calculating correctly and the scrollbar not appearing.
https://gfycat.com/V...dAsiandamselfly
 
It looks like TNxCustomGrid6... function SumCol iterates through the rows...
 
Here's what I found: If I add (1) Parent with (10) Children. The first time through, i == 0, Cell[Index, i].AsFloat == 0

.
When a second row is added, the first row that's found with a value >0 is at index 0, and the row at index 11, which should have the second value i == 11, Cell[Index, i].AsFloat == 0.
 
Basically, the last row that's added is always 0 so the sum is always off by the value of whatever is in the most recently added row.
It's acting like TNxCustomGrid6.Recalculate is being called before the value in the last added (row) cell exists.
 
Thanks!

Thanks I fixed sum problem. It was my bug. I will work now on scrollbar (which is always tricky :( ).

I will upload new update tonight.
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.

#119 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 27 July 2018 - 09:38 PM

Thanks I fixed sum problem. It was my bug. I will work now on scrollbar (which is always tricky :( ).

 

I will upload new update tonight.

 

Great, thank you. I'm just curious, what was the issue with the footer? Was my assessment correct?



#120 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 27 July 2018 - 10:06 PM

I was calling Recalculate in EndUpdate method without need. You can try also if you delete this line, but then you need to se AutoCalculate property to true.
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users