Windows10, Delphi 12.3 , NextGrid 6.40.
Foot.FormulaKind is fkMaximum or fkMinimum . the result is incorrect.
and i don't know how to focus on the specific cell.
Thanks!
Posted 05 July 2025 - 04:53 AM
Windows10, Delphi 12.3 , NextGrid 6.40.
Foot.FormulaKind is fkMaximum or fkMinimum . the result is incorrect.
and i don't know how to focus on the specific cell.
Thanks!
Posted 05 July 2025 - 05:51 PM
Hello,
I think that I have almost fixed it. I have a problem with value 0, so I decided to use NaN instead.
I think I will send the fix at the end of the day. Thank you for your demo project, it really helped.
Posted 05 July 2025 - 10:49 PM
Hello Sir,
Please replace this method in full (copy and paste the code). It is located in NxCustomGrid6.pas under Sources\Next Grid
procedure TNxCustomGrid6.Recalculate;
var
Count, i: Integer;
CaltulatedValue: Double;
function SumCol(Index: Integer): Extended;
var
i: Integer;
begin
Result := 0;
for i := 0 to Pred(RowCount) do
begin
if (roExcludeInvisible in FCalculateOptions)
or Row[i].Visible then Result := Result + Cell[Index, i].AsFloat;
end;
end;
function CalcCol(Index: Integer; Kind: TNxFormulaKind): Extended;
var
i: Integer;
Value: Double;
s: WideString;
sl: TStringList;
begin
case Kind of
fkMaximum, fkMinimum: Value := NaN
else Value := 0;
end;
case Kind of
fkAverage: Value := SumCol(Index) / Count;
fkCount: Value := Count;
fkShowingCount: Value := ShowingCount;
{ Loop trough all and call OnCalculate }
fkCustom:
for i := 0 to Pred(RowCount) do
if (not (roExcludeInvisible in FCalculateOptions) or Row[i].Visible)
and CanCalculate(i) then
begin
Columns[Index].DoCellCalculate(Index, i, Value);
end;
fkDistinct:
begin
sl := TStringList.Create;
for i := 0 to RowCount - 1 do
if (not (roExcludeInvisible in FCalculateOptions) or Row[i].Visible) { visible only }
and CanCalculate(i) then
begin
s := Cells[Index, i];
if sl.IndexOf(s) = -1 then
sl.Add(s);
end;
Value := sl.Count;
FreeAndNil(sl);
end;
fkMaximum:
for i := 0 to Pred(RowCount) do
if (not (roExcludeInvisible in FCalculateOptions) or Row[i].Visible)
and CanCalculate(i)
and ((Cell[Index, i].AsFloat > Value) or IsNan(Value))
then Value := Cell[Index, i].AsFloat;
fkMinimum:
for i := 0 to Pred(RowCount) do
if (not (roExcludeInvisible in FCalculateOptions) or Row[i].Visible)
and CanCalculate(i)
and ((Cell[Index, i].AsFloat < Value) or IsNan(Value))
then Value := Cell[Index, i].AsFloat;
fkSum: Value := SumCol(Index);
end;
{ Done }
Result := Value;
end;
begin
Count := RowCount;
for i := 0 to Pred(Columns.Count) do
with Columns[i].Footer do
begin
CaltulatedValue := CalcCol(i, FormulaKind);
{ Trigger event }
Columns[i].DoCalculated(i, CaltulatedValue);
{ Trigger event of the Grid }
DoFooterCalculated(i, CaltulatedValue);
Value := CaltulatedValue;
end;
WritelnDebug('Recalculate');
end;
Posted 06 July 2025 - 03:54 AM
Thanks!![]()
NextSuite v6 - VCL Components →
NextGrid v6 Component →
NextGrid 6 - footer top display other text shadowStarted by Ken, 03 Oct 2024 |
|
|
||
NextSuite v6 - VCL Components →
NextGrid v6 Component →
Adding or changing the values of a NxListColumn6Started by ouiji, 18 Apr 2024 |
|
|
||
NextSuite v6 - VCL Components →
NextGrid v6 Component →
Tnextgrid6.EditCell gives inaccurate resultStarted by bicks, 18 Apr 2020 |
|
|
||
![]() |
tips
NextSuite v6 - VCL Components →
NextGrid v6 Component →
Tips & TricksStarted by Boki (Berg), 05 Apr 2016 |
|
|
0 members, 6 guests, 0 anonymous users