Jump to content


Photo

NextGrid5 -> NextGrid6 upgrade


  • Please log in to reply
126 replies to this topic

#81 BelangerC

BelangerC

    Senior Member

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

Posted 06 July 2018 - 10:07 AM

Hi, Boki:

 

In NG5 there is a OnEditText event that I have been using with this grid. From what I can see there is an OnCellChange event. Would that work for this event conversion? Or would another work better?

 

Thank you.

 

WITH Grid DO
  BEGIN
    // if first column of ad hoc row exceeds 512 cc max, then do something
    IF (ACol = 0) AND (Pos('UR', string(Cell[Columns.Count - 1, aRow].asString))
      > 0) AND (Length(Value) > 512) THEN
    BEGIN
      // 5/23/09
      DoFPShowMessage('Cell Text exceeded max 512 characters.' + CR +
        'Text truncated.', 3000);
 
      Value := Copy(Value, 1, 512);
    END;
  END; // with grid


#82 BelangerC

BelangerC

    Senior Member

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

Posted 06 July 2018 - 10:50 AM

Hi, Boki:

 

From my post in March, 2018:

  a. OnCellFormatting; this really needs to be at the grid wide level; OnSetCell at the column level just does not work for my application.

 

This is my notes on it:

OnCellFormating = Columns.OnSetCell procedure TForm1.NxTreeColumn61SetCell(Sender: TObject; ACol, ARow: Integer;  Cell: INxBaseCell); THE PROBLEM IS THAT CELL does not have Font settings! Need to reference the Columns(ACol).Font

 

If I remember correctly, whether a Cell has font settings is determined by the type of column. It is so much cleaner to have a grid wide event which takes care of setting all column font settings.

 

I would really appreciate it if you can add back a grid level event to act like the NG5 OnCellFormatting.

 

Thank you,

Chuck

 

 

I am using OnCellFormatting in the single NG5 grid conversion. Here is how I am using it:

 

WITH Grid DO

  BEGIN
    // the trick for this to work is not to use FullRowSelected, otherwise,
    // only the NON selected cells are formatted.
 
    // if (csSelected in CellState) then
    // 5/20/13 do not include any columns with name 'Hidden'
    if (Pos('HIDDEN', UpperCase(Columns[ACol].Name)) = 0) then
    begin
      IF (SelectedRow = aRow) AND (SelectedCol = ACol) then
      // this works with SelectFullRow option
      BEGIN
        TextColor := clBlack;
        FontStyle := [fsBold];
      END
    end
    else
    begin
      TextColor := Columns[ACol].Font.Color;
      FontStyle := Columns[ACol].Font.Style;
    end;


#83 BelangerC

BelangerC

    Senior Member

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

Posted 06 July 2018 - 11:02 AM

Hi, Boki:

 

Here are the final items, as far as I can tell without actually running the program with a NG6 grid:

 

Need Grid.GetLastChild method.

 

How do I get RowHeight of a particular row? In NG5, RowHeight[aRow].

 

 

 

 

 

I am pretty sure this is everything that I need for this grid conversion.

Thank you!

Chuck



#84 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 03:51 PM

Hi, Boki:
Thank you for your response. I will look at that and let you know if I have further questions.
Here is another:
 
Missing Grid.GetCellTop.
 
In a routine called by OnCellDblClick, I create a panel which lays over the grid's cell. Here is the routine to show the use of GetCellTop in context: Thank you for your help in either adding this method or pointing me to another that would give me what I need.
Chuck
 
With Grid do
begin
WITH WizTableCellPanel DO
          BEGIN
            // 0th col, thus only left side of cell
            // PanelStart := GridSpace[TGridLinePosition(lpLeft)];
            PanelStart := 0;
 
            Parent := Grid;
            Align := alNone;
            BevelOuter := bvRaised;
            // 3/26/08 do not make wider but make longer for larger fonts. Similar
            // in principle to WizAddRTFtoLabel, but in multiple units of row height
            // 10/22/08 make it the same height as the Row for now
            // Below height is arbitrary and reset below RTF creation to match the actual text
            Height := Trunc(1.5 * RowHeight[SelRow]);
            // RowSize; is the general setting; not specific row
            // add width of indicator
            // Left := Trunc((Gridview1.Width-GridView1.InnerWidth)/2) + PanelStart;
            //2/20/18 ActiveView now
            CellRect := ActiveView.GetCellRect(SelCol, SelRow);
 
            Left := CellRect.Left;
 
            Name := 'plTableCell';
 
            // Top := HeaderSize + GridSpace[TGridLinePosition(lpTop)];
            Top := GetCellTop(SelCol, SelRow);
            Width := Columns[SelCol].Width;
            Visible := True;
            Caption := '';
 
          END; // WizTableCellPanel
End;


Hi,

You can use GetItemTop event of ActiveView. But I think now that I will return GetRowTop function to the Grid itself too.
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.

#85 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 03:58 PM

Hi, Boki:
 
Could you please direct me to an alternative to how I have been using Grid.GetLevel? Thank you!
 
Here is another apparent missing method:
 
Grid.GetLevel
 
In an OnDragOver event I have the following code to show the context of how I use GetLevel:
 
 var
    GridSource, GridSender : TNextGrid6;
    SourceRow, SenderLevel : Integer;
 
begin
 // need this to determine if source and sender agree for application and
    // for Drag/Drop to even work
 
    // This event affects dragging intitiated by the grid itself, i.e. in setting row index
    // Restrictions: must be to itself; must be a visible row; must be at the same level
    // as the selected row
    // Reason: you would have to update the Parent_ID in the table; it doesn't make
    // much sense; and this way you can rely on the close session to call the reset index
    // routine which sets the table to the new index
 
    //2/27/18 In order to cast ActiveView, I need to disconnect the Grid from the phrase
    //Thus all this code to isolate the grids
 
    if (Sender is TNextGrid6) and (Source is TNextGrid6) then
    begin
     GridSource := Source;
     GridSender := Sender;
 
     with GridSource do
     begin
      SourceRow := TNxReportGridView6(ActiveView).GetItemAtPos(x,y);
     end;
     with GridSender do
     begin
       SenderLevel := GetLevel(TNxReportGridView6(ActiveView).GetItemAtPos(X, Y));
     end;
    end;
 
     if (SourceRow > -1) and (SenderLevel = Wizard.RowLevelBeingDragged ) then
 
      //(TNextGrid6(Source).GetRowAtPos(X, Y) > -1) and
      //(TNextGrid6(Sender).GetLevel(TNextGrid6(Sender).TNxReportGridView6(ActiveView).GetItemAtPos(X, Y))
     // = Wizard.RowLevelBeingDragged) then
      Accept := True
    else
      Accept := FALSE;


You can access Row array property and then simply inspect Level sub-property.
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.

#86 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 03:59 PM

Hi, Boki:
 
Here are the final items, as far as I can tell without actually running the program with a NG6 grid:
 
Need Grid.GetLastChild method.
 
How do I get RowHeight of a particular row? In NG5, RowHeight[aRow].
 
 
 
 
 
I am pretty sure this is everything that I need for this grid conversion.
Thank you!
Chuck


Hi,

I suggest simply using Height property of Row. I will add now method for LastChildren.
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.

#87 BelangerC

BelangerC

    Senior Member

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

Posted 09 July 2018 - 05:09 PM

Hi,

You can use GetItemTop event of ActiveView. But I think now that I will return GetRowTop function to the Grid itself too.

 

Hi, Boki:

 

GetItemTop is not available for ReportGridView which is what I have been using exclusively. It is only available for List or Slides. Either needs to be included for Reports or as you say added to the Grid. Thank you.



#88 BelangerC

BelangerC

    Senior Member

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

Posted 09 July 2018 - 05:26 PM

You can access Row array property and then simply inspect Level sub-property.

I am trying to replace:

SenderLevel := GetLevel(TNxReportGridView6(ActiveView).GetItemAtPos(X, Y));

 

 When I use 

SenderLevel := Row[TNxReportGridView6(ActiveView).GetItemAtPos(X,Y)].Level does not exist, yet I see the property in NxCells6.pas. 

How do I access Row[].Level?

Thank you,

Chuck



#89 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 05:30 PM

Hi, Boki:
 
GetItemTop is not available for ReportGridView which is what I have been using exclusively. It is only available for List or Slides. Either needs to be included for Reports or as you say added to the Grid. Thank you.


Hi,

ReportView is inherited from ListView. You should see this method.

For example NxReportGridView61.GetItemRect or GetItemTop
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.

#90 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 05:31 PM

When I use 
SenderLevel := Row[TNxReportGridView6(ActiveView).GetItemAtPos(X,Y)].Level does not exist, yet I see the property in NxCells6.pas. 
How do I access Row[].Level?
Thank you,
Chuck


Hi,

NextGrid include Row property. You only need to give Index. For example:

MyLevel := NextGrid61.Row[4].Level;

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.

#91 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 09 July 2018 - 07:22 PM

In next release there will be LastDescendant property to INxRow (Grid.Row[x]). Currently you have LastChild that return last child but only in next level.
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.

#92 BelangerC

BelangerC

    Senior Member

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

Posted 10 July 2018 - 12:08 AM

Hi,

NextGrid include Row property. You only need to give Index. For example:
 

MyLevel := NextGrid61.Row[4].Level;

Thank you. Turns out in my actual code I typed Row(<expression>), not Row[<expression>]. That worked with LEVEL.



#93 BelangerC

BelangerC

    Senior Member

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

Posted 10 July 2018 - 12:29 AM

Hi,

ReportView is inherited from ListView. You should see this method.

For example NxReportGridView61.GetItemRect or GetItemTop

 

Hi, Boki:

I can access ActiveView (as NxReportGridView6).GetItemRect, but not GetItemTop. 

 

Earlier in code I got the cell rectangle and just used CellRect.Top. I am thinking that should work.

 

So, I notice that both of these statements are allowed. Are they the same?

 

CellRect := ActiveView.GetCellRect(SelCol, SelRow);
CellRect := ActiveView.GetItemRect(SelCol, SelRow);


#94 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 10 July 2018 - 02:40 AM

Hi,

Cell is usefull for other views such as slideview. There not all cells are in same line. But in report, they are.
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.

#95 BelangerC

BelangerC

    Senior Member

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

Posted 10 July 2018 - 04:00 AM

Hi, Boki:

 

Can you tell me the status of the following recent questions:

 

1. Getting Grid.OnCellFormatting event back (vs. Columns.OnSetCell which is much more tedious to use and cannot be globally set for entire grid; only certain columns can set Cell Formatting).

 

2. OnVertical/HorizontalScroll: getting back the Position var.

 

3. Is OnCellChange (ng6) the same as NG5 OnEditText?

 

These are the only things stopping me from converting this single NG5 grid at this point.

 

Thank you,

Chuck



#96 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 10 July 2018 - 06:05 PM

1) There is a OnStyleText event, again for column. But you can easily link several columns to one event handler.

2) There is already Position property to scroll bar.

3) Please read next, maybe this is what you need:

OnInplaceEditChange

Occurs after edit's value, or some other important property is changed. When this event is triggered depends on specific implementation but it is usually after user change value.
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.

#97 BelangerC

BelangerC

    Senior Member

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

Posted 11 July 2018 - 03:15 PM

1) There is a OnStyleText event, again for column. But you can easily link several columns to one event handler.

 

In NG5:OnColumnFormatting I am trying to set the font as black and the fontstyle as bold for any selected row/col; if not a selected row, then whatever the font settings are.

The problem with OnStyleText (or OnSetCell) is that not every column has this event (e.g. CheckBox columns) and thus there will not be a consistent bold and black font across a selected row. So, maybe the better question is what is the best way to achieve this selected row look? I see the Grid6 has SelectionTextColor, but not SelectionFontStyle. Thus my request for a Grid wide event to handle this, such as OnCellFormatting. Thank you.



#98 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 12 July 2018 - 02:31 PM

Hi Chuck,

Can you send me screenshot of row from previous version what you want to achieve?

I will add this event also to CheckBox column. Actually it should be there from start :)
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.

#99 BelangerC

BelangerC

    Senior Member

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

Posted 12 July 2018 - 04:07 PM

Hi, Boki:

 

Thank you.

 

Attached is the screen shot of the grid that I have selected to convert in my program. This is the previous version using NG5. 

I notice that the check box does not become font style BOLD in the old grid either.

I did check and NG6 combo box and number columns do become bold (these are the other column types beside Tree and Text which I use mostly).

 

The yellow cell is the selected cell. The bold/black text is also used for mouse over movement.

 

BTW, this is the NG5 grid that I originally mentioned that for whatever reason redraws  with parts of the screen embedded in its image. To overcome this I REPAINT in almost every interaction with the grid. Even  then sometimes it still repaints either as completely black, i.e. no image of the grid, or with pieces of the screen other than the grid.

 

Chuck

 

 

Attached Files



#100 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 12 July 2018 - 11:35 PM

Hi,

For this purpose maybe you can simply enable aoBoldSelectedText flag in AppearanceOptions of TNextGrid6?

But I will add event to checkbox column anyway.
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