Jump to content


Photo

Triggering Grid Footer Calculate


  • Please log in to reply
6 replies to this topic

#1 PhilW

PhilW
  • Members
  • 75 posts

Posted 31 October 2008 - 12:38 PM

Hi, Boki; hi, everybody,

I recently purchased the component suite and I am very pleased with it, thank you.

A quick question:

I am using a NxDBGrid in a typical master/detail form; several of the columns have footer totals. I can trigger the CalculateFooter method when the record changes by using the datasource DataChange event.
However, I don't know how to calculate the footer on the initial display of the grid after the dataset is opened. Which event would you recommend to use to show the footer totals on the first record?

Thanks for any advice,
Phil.

#2 PhilW

PhilW
  • Members
  • 75 posts

Posted 31 October 2008 - 05:25 PM

Hi,

Issue resolved - I simply put a CalculateFooter call in the FormCreate section, after the table is opened.

Thanks,
Phil.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 31 October 2008 - 07:20 PM

Hello Phil,

I am glad that you have solve it.

Best regards
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.

#4 PhilW

PhilW
  • Members
  • 75 posts

Posted 01 November 2008 - 05:09 PM

Hi,

I know it is bad form to reply to one's own messages, but I would like to give a headsup to everyone using FooterCalculate in a NextDBGrid to be careful where in your code the method is called.

So: when the user edits a cell in the column, it would be tempting to have the total recalculated by the OnAfterEdit event:

// PROBABLY BAD CODE! - DO NOT COPY!
procedure TForm1.NextDBGrid1AfterEdit(Sender: TObject; ACol, ARow: Integer; Value: WideString);
begin
if ACol = 4 then NextDBGrid1.CalculateFooter; //Quantity column
end;

But the changed record has not been posted yet - perhaps the user will cancel the edit? So, probably better would be the recalculate the footer in the dataset's afterpost event instead.

Just a thought,
Phil.

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 01 November 2008 - 07:39 PM

Hello,

I think that the best place for puting this code may be in OnDataChange of DataSource.

So, I suggest checking some of this events (From TTable, TQuery...)

Best regards
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.

#6 sandokhane

sandokhane
  • Members
  • 4 posts

Posted 15 April 2015 - 12:42 PM

when i call calculatefooter i have a result for visible rows only ;

how can i have result for all rows ?



#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 16 April 2015 - 12:13 AM

Hi,

 

Not sure if this is related to NextGrid, where you can set parameter VisibleOnly inside CalculateFooter method.


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