Topic: Excluding blank cells on footer count?

How to exclude blank cells on footer count?
https://images2.imgbox.com/7e/ae/62kozORB_o.jpg

Post's attachments

Attachment icon FooterCount.zip 6.57 kb, 156 downloads since 2022-03-10 

Adam
God... please help me become the person my dog thinks I am.

Re: Excluding blank cells on footer count?

Hi,
Disable automatic counting.
Manually in a script, create a loop in the ONCHANGE event over the total number of rows.
Count rows with non-zero cell. (property Cell[x,y]: TCell Empty: Boolean (description in manual))
Put the value in the footer.

3 (edited by AD1408 2022-03-10 14:30:17)

Re: Excluding blank cells on footer count?

Hi sparrow,
Thanks but I'd appreciate showing the working version using the sample project I've included with my post above please.

Adam
God... please help me become the person my dog thinks I am.

Re: Excluding blank cells on footer count?

anybody?
sample project on post#1

AD1408 wrote:

How to exclude blank cells on footer count?
https://images2.imgbox.com/7e/ae/62kozORB_o.jpg

Adam
God... please help me become the person my dog thinks I am.

Re: Excluding blank cells on footer count?

Hi Adam,
Could you do it like this?  (see attached).
Derek.

Post's attachments

Attachment icon mtv 2.zip 336.9 kb, 163 downloads since 2022-03-13 

Re: Excluding blank cells on footer count?

Hello Derek

Is it voluntarily that the calculation of the footer is only updated under the following condition:
From your example, I added a parent (the company CESSNA).
The footer keeps the same value (2 for AIRBUS + BOEING)
It seems that CESSNA is not included in the count.
But if I add a child under CESSNA, the total is updated.
Does this mean that as long as the parent does not have a child, it is not counted?
Or is it due to the "distinct parentid" condition?
Thank you for your answer

Cordially
JB

Re: Excluding blank cells on footer count?

Hi Jean,
Good to hear from you.
I guess it depends on what Adam is after
a)  the number of top level nodes
or
b)  the number of top level nodes with children
I've amended the previous attachment to show both just in case.
Regards,
Derek.

Post's attachments

Attachment icon mtv 2a.zip 337.21 kb, 138 downloads since 2022-03-13 

Re: Excluding blank cells on footer count?

Derek
Thanks for your new example..
It's very clear. It all depends on the type of calculation desired:
global or detailed.
Cordially
JB

9 (edited by AD1408 2022-03-13 20:30:25)

Re: Excluding blank cells on footer count?

Hi Derek,


Thank you so much for your kind attention. Example you provided is not what I was asking for but it'll be useful in other projects.


What I like to do is that use the count function on Tablegrid (not Treeview nodes) without counting blank cells. In other words only cells containing something in it (text, numbers etc) are counted. Please see the image below:
https://images2.imgbox.com/7e/ae/62kozORB_o.jpg


Hi Jean,
Nice to see you around too.

Adam
God... please help me become the person my dog thinks I am.

Re: Excluding blank cells on footer count?

Hi Adam,
Sorry - wasn't paying attention!
You could try doing it something like this (see attached).
Derek.

Post's attachments

Attachment icon rowcount.zip 351.89 kb, 161 downloads since 2022-03-13 

11 (edited by AD1408 2022-03-14 09:31:27)

Re: Excluding blank cells on footer count?

Hi Derek,


Great stuff as usual.
Thank you very much....
Truly appreciated....


------------------------------------------------------------


I have tried the following for counting additional rows but failed;

procedure Form1_TableGrid1_OnChange (Sender: TObject);
begin
  OnChange1;
  OnChange2;
end;

procedure OnChange1;
var  vi: integer;
begin
form1.edit1.Value := 0;
for vi := 0 to form1.tablegrid1.rowcount -1 do
   begin
   if form1.tablegrid1.cells[0,vi] <> '' then form1.edit1.value := form1.edit1.value + 1;
   end;
form1.tablegrid1.columns[0].footer.caption := form1.edit1.text;
end;


procedure OnChange2;
var  va: integer;
begin
form1.edit2.Value := 0;
for va := 0 to form1.tablegrid1.rowcount -1 do
   begin
   if form1.tablegrid1.cells[1,va] <> '' then form1.edit2.value := form1.edit1.value + 1;
   end;
form1.tablegrid1.columns[1].footer.caption := form1.edit2.text;
end;
Adam
God... please help me become the person my dog thinks I am.

Re: Excluding blank cells on footer count?

Hi Adam,
I imaging it's because in counting the second column, you are mixing your counters.  You have the following
.
....then form1.edit2.value := form1.edit1.value + 1;
Instead of
....then form1.edit2.value := form1.edit2.value + 1;
.
But there is no need to use a separate counter (edit2) - just re-use (edit1) and simply chance column[0] to column[1]  (see attached).
Derek.

Post's attachments

Attachment icon rowcount2.zip 352.33 kb, 148 downloads since 2022-03-14 

Re: Excluding blank cells on footer count?

Hi Derek,
Looks like my one cell brain played a trick on me again.
Thank you very much for your kind attention.....

Adam
God... please help me become the person my dog thinks I am.