Jump to content


Photo

Clearing fields


  • Please log in to reply
4 replies to this topic

#1 Lothar

Lothar
  • Members
  • 16 posts

Posted 03 February 2021 - 07:08 PM

Hello,

 

I have integer fields in the database which I can edit in NextDbGrid - also TNxDbLookupColumn-fields.

1. How do I empty them - get null in the Database?

    That doesn't work: "  nxgrdVermBericht.Cell[nxgrdVermBericht.SelectedCol, nxgrdVermBericht.SelectedRow].Empty := True;"

2. if TNxDbLookupColumn are null (new record) and I click on them it says "Variante des Typs (OleStr) konnte nicht in Typ (Integer) konvertiert werden" => "Typ OleStr couldn't be converted into Typ Integer"

   how can it show empty when there is null in the database?

 

kind regards,

Lothar



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 05 February 2021 - 01:18 PM

Hi,

 

Please sorry for delay,

 

I suggest that you clear fields directly, by accessing Field and then calling Clear:

http://docwiki.embar...DB.TField.Clear

 

Grid will then catch up.

 

I hope that this helps.


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 Lothar

Lothar
  • Members
  • 16 posts

Posted 08 February 2021 - 10:07 AM

Hi Boki,

 

thank you, but I don't get it to work:

I use a popup-Menu to clear the field:

procedure THaWjStammDlg.mniClearClick(Sender: TObject);
var
 Browse : Boolean;
begin
  Browse := nxgrdVermBericht.DataSource.DataSet.State = dsBrowse;
  if Browse then
    nxgrdVermBericht.DataSource.DataSet.Edit;
  nxgrdVermBericht.DataSource.DataSet.FieldByName(nxgrdVermBericht.DataBinding[nxgrdVermBericht.SelectedCol].FieldName).Clear;
  if Browse then
    nxgrdVermBericht.DataSource.DataSet.Post;
end;

strangely it doesn't change the database.

 

AND do you have an answer for Question 2?



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 08 February 2021 - 12:35 PM

Hi,

 

1) Pretty strange that it doesn't work, as it should be not related strictly to the Grid.

 

It is also important to note that only fields inside selected record will be updated. Maybe he cleared some other record (after doing the test)? I will try to do some tests about it.

 

2) I will check this and probably fix it.


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 Lothar

Lothar
  • Members
  • 16 posts

Posted 09 February 2021 - 11:08 AM

Hi Boki,

 

1) even with a locate to the right row it doesn't work - verry strange.

 

procedure THaWjStammDlg.nxgrdVermBerichtContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
var
  Point : TPoint;
begin
  Point := nxrpt.GetCellAtPos(MousePos);
  if (Point.X >= 1) and (Point.Y >= 0)then
  begin
    if nxgrdVermBericht.DataSource.DataSet.Locate('vb_key', nxgrdVermBericht.Cell[nxnrVB_KEY.Position,Point.Y].AsString, []) then
      pmClear.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
  end;
end;

 






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users