TClientDataSet aggregate fields... any way to provide a default value for when the dataset is empty?

TClientDataSet aggregate fields... any way to provide a default value for when the dataset is empty?

I need to track "remaining number of items" (ie "N - Sum(Field)" style) for several fields, so need to display total when the dataset is empty. Would be nice not to track it manually.

I suppose I could use the GetText event but... is there a better way?

Comments

  1. First of all, make sure your grouping level is correct.
    Once you have that, you can use GetGroupState to check where you are in the group: first, middle or last.
    Needless to say, you want to check your LAST value and then use some form of comparison of some value that changes across groups,
    therefore keeping a count of how many lines have been processed as part of the current group.
    You should be able to go from there by using a calculated field in addition to the aggregate one.

    Makes sense?

    ReplyDelete
  2. Thanks, using a calculated field did the trick. I put the calculated fields in a separate TClientDataSet, and refresh it when needed (OnAfterPost etc).

    ReplyDelete

Post a Comment