Jump to content


Photo

AddRow when fields are "not null"

AddRow not null

  • Please log in to reply
3 replies to this topic

#1 Lothar

Lothar
  • Members
  • 9 posts

Posted 04 February 2019 - 05:25 PM

Hello Boki,

 

I have problems adding Rows in the TNextDBGrid6 when fields of the database are not allowed to be null.

 

In function TNxDBCellSource6.AddRow

      FDataLink.DataSet.Append;
      FDataLink.DataSet.Post;
 

there is no chance to add data before the post.

 

Also the function AddCells uses with AddRow the post before the data gets inserted.

 

Ho should I proceed?

 

Thankis in advance

Lothar



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,815 posts
  • Gender:Male

Posted 04 February 2019 - 11:10 PM

Hi,

Every column have DefaultValue property which you may set and then when calling AddRow set IgnoreDefaults parameter to False.

AddRow method may be handy for simple use, but I will always call Append, Post etc. manually on TDataSet.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.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 Lothar

Lothar
  • Members
  • 9 posts

Posted 05 February 2019 - 12:35 PM

Hi Boki,

 

thank you for your hints.

 

Both ways don't work.

 

1. So I use Append, Post etc. manually on TDataSet.

 

I can see the new row in the database - BUT the grid doesn't show the new line.

I tried with

- Refresh

- Update

- DataChanged([uoRecount])

- RowsChanged

 

2. Setting DefaultValue and calling AddRow set IgnoreDefaults parameter to False doesn't work because the filling with the default Values happens AFTER the post.:

function TNxDBCellSource6.AddRow(const Count: Integer;
  IgnoreDefaults: Boolean): INxCellsRow;
....

...

      FDataLink.DataSet.Append;
      FDataLink.DataSet.Post;

      if not IgnoreDefaults
        then AssignDefaultValues(RecordCount + i);

 

 

 

Lothar



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,815 posts
  • Gender:Male

Posted 06 February 2019 - 02:09 AM

Hi,

Sorry about my mistake for 2nd solution. I missed this.

Grid should be updated automatically on any TDataSet change. When TDataSet is changed (for example when you call Append) number of buffered records should be updated.

This can be seen at line 661.

Maybe you can set breakpoint there and see if code stops. Different TDataSet implementations unfortunately work different in Delphi (even in theory they all should be same) so maybe is due to database technology you use.

Another solution is that I made for you method like ForceRecount but maybe it will be nice to solve solution from core and see why DataChange is not triggered.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.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