Jump to content


Photo

Clicking the checkbox doesn't fire Before/After edit events.


  • Please log in to reply
8 replies to this topic

#1 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 25 October 2016 - 04:52 PM

It did before, and altering the checkbox is an edit of the boolean state.  Is there a reason why it doesn't use these events? I can use the column's OnCheckedChanged, but you can't preempt the check from happening since change is after it's happened.

 

I want to preempt the change from occurring.



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 25 October 2016 - 08:04 PM

Hi,

Please sorry for delay,

I will need to solve this in different way, since checkbox column is different than other "text/TEdit" type of columns. Maybe better solution will be to have OnBeforeCheck event?
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 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 25 October 2016 - 08:15 PM

 

Maybe better solution will be to have OnBeforeCheck event?

 

That would probably be fine.



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 30 October 2016 - 11:58 PM

Hi,

 

I have added it. It will be included in next update.

 

It's called OnCheckedQuery (with var Accept parameter), hope that name is also good.


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 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 01 November 2016 - 10:26 PM

Hi,

 

I have added it. It will be included in next update.

 

It's called OnCheckedQuery (with var Accept parameter), hope that name is also good.

 

Sounds fine.  Naming things is one of the most difficult problems in computer science. :)



#6 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 13 December 2016 - 10:10 AM

This works, thank you.

 

One minor bug though.

 

After clicking the checkbox and it firing CheckedQuery, the grid OnCellChange reports the column changed as the incorrect index.

For example, my checkbox is column 0, and it's reporting 9 as changed which wasn't altered.

 

Inside CheckedQuery I am reading a value from the grid at the column index that matches the column OnCellChange is reporting as the changed column.

 

If I remove this, it works fine. If possible, I need to be able to read values from grid within CheckedQuery and still have OnCellChange work as expected.

procedure TFormViewForfeitPreview.ChkBoxCheckedQuery(Sender: TObject;
  ACol, ARow: Integer; var Accept: Boolean);
var
  i: Integer;
begin
  inherited;
  Accept := True;
  if not(grid.Cell[ACol, ARow].AsBoolean) then
  begin
    for i := 0 to SelectedItems.Count -1 do
    begin
      if (SelectedItems.ValueFromIndex[i] <> grid.Cell[9, ARow].AsString) then
      begin
        ShowMessage('Items from previous dates cannot be saved with items for the current day.');
        Accept := False;
        Break;
      end;
    end;
  end;
end;


#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 13 December 2016 - 05:03 PM

Hi,

Please try to change this code. Copy/paste over the whole procedure in NxColumnViewClasses6.pas file (Sources\Next Grid).

Tell me if is good now, so I can include it in official release.

procedure TNxCheckBoxColumnView.SetAsBoolean(const Value: Boolean);
var
  Accept: Boolean;
begin
  Owner.LocateCell(Location.X, Location.Y);

  Accept := True;

  { Trigger event }
  CheckBoxColumn.DoCheckedQuery(Location.X, Location.Y, Accept);

  if Accept then
  begin
    { `OnCheckedQuery` can change location }
    Owner.LocateCell(Location.X, Location.Y);

    CheckBoxColumn.SetValue(Cell, Location.X, Location.Y, Value);

    { Trigger event }
    CheckBoxColumn.DoCheckedChanged(Location.X, Location.Y);
  end;
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.

#8 FourWhey

FourWhey
  • Members
  • 165 posts

Posted 13 December 2016 - 06:05 PM

Yes, this works.  Thank you.



#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 13 December 2016 - 06:32 PM

Good, I will include it in next release.

Thanks.
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.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users