Jump to content


Photo

Two problems with NxDBGrid FooterCalculate


  • Please log in to reply
6 replies to this topic

#1 PhilW

PhilW
  • Members
  • 75 posts

Posted 02 November 2008 - 11:41 AM

Hi, Boki,

I have come across two issues with the FooterCalculate code, one to which I have found the solution, the other not.

1. First, the easy one:

at line 940 of NxDBGrid.pas:
fkCustom: DoColumnFooterValue(Column.Index, FormulaSum);

should be amended to:
fkCustom:
begin
DoColumnFooterValue(Column.Index, FormulaSum);
Result := FormulaSum;
end;

otherwise the function CalculateColumn always returns zero for columns with a FormulaKind of fkCustom.

2. The second issue raises an EOleException error (I am using an ADO dataset) at line 920 of NxDBGrid.pas:
..
case FormulaKind of
fkSum, fkAverage: FormulaSum := FormulaSum + GetFieldValue(Column.Field);
...

when FooterCalculate is called when the dataset is in edit state. (There is no error if the dataset is in browse state). Unfortunately I cannot find the cause nor a solution to this.

The error message is: "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another".

Not good. mad.gif
Phil.

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 03 November 2008 - 09:12 PM

Hello Phil,

I have fix 1st one, but not receive error on 2nd one. Maybe you can build for me one small demo application to I fix it.

Thank you
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 PhilW

PhilW
  • Members
  • 75 posts

Posted 04 November 2008 - 01:36 PM

Hi, Boki,

Demostration project attached (FooterBugDempProject.zip 18Kb).

Description
-------------
The form has a NextDBGrid, a label and a button.
- The grid loads data, via a ADOTable, into two columns, one of which is a TNxDBNumberColumn with a ftSum footer.
- The label shows the state of the dataset (Browse, Edit, etc)
- The button triggers the grid FooterCalculate method.

Reproduce the FooterCalculate bug
----------------------------------------
When the dataset is in Browse state, click the button - the FooterCalculate works.
Click the grid to put the dataset into Edit state, click the button - Crash, Bang, Wallop, Exception!

Best of luck and good hunting!
Regards,
Phil.

Attached Files



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 04 November 2008 - 02:12 PM

Hello Phil,

Try to add this line at the beginning of CalculateColumn

CODE
  if FDataLink.Editing then FDataLink.DataSet.Cancel;


Please tell me how it works now.

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.

#5 PhilW

PhilW
  • Members
  • 75 posts

Posted 05 November 2008 - 01:47 PM

Hi, Boki,

Unfortunately, due to being well behind in my current development (not all due to the issues with the footer calculate code) I cannot afford to spend any more time on this matter.

As I mentioned earlier, from a design point of view, it is probably not a good idea to calculate totals while still in Edit or Insert mode; so the fact that the code does not allow it maybe seen as a feature. rolleyes.gif

Your suggested fix, if it does what I think it does, is not the solution.

My workround, and what I would recommend to other users of NextDBGrid with ADO datasets, is to keep to ftCustom footers and calculate totals or whatever yourself by looping through the records. This is what the code is attempting to do anyway and so there is no performance penalty.

Kind regards,
Phil.

#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 05 November 2008 - 04:14 PM

Hello Phil,

Problem with calculating NextDBGrid is that there are 2 modes: buffered and non-buffered. The best solution is to simply do calculations by yourself and then put it in Footer.Caption.

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.

#7 alpay.abay

alpay.abay
  • Members
  • 1 posts

Posted 06 January 2013 - 12:09 AM

Hi Boki,

I was working on a new project. and I have the same problem. In buffered mode if you go in insert state it raises "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another." error. Is there any further development on this issue?

Friendly Regards




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users