I have a wholesale base total that is calculated off of a specifications table. This aggregate is too complicated for the Expression property of a DataColumn because it involves rounding and excluding part of the DataTable.
Therefore, I am calculating it myself as the following DataTable events occur: ColumnChanged (only if it is the total column), RowChanged (only if it is an DataRowAction.Add change), and RowDeleted. I am using the following code:
The problem is that the RowChanged event occurs BEFORE the new row is actually added to the DataTable so the result of the Compute method is less the added row.
All other events work fine. RowDeleted occurs after the row is actually removed from the DataTable, ColumnChanged occurs after the column values are actually changed.
My workaround is to add the value of the added row onto the result of Compute only for that event.
I've also tried using an aggregate column such as:
Even though the result does not produce what I need, I was hoping that the DataTable would provide proper notification of a change to that column in ColumnChanged at which point I could trigger my custom calculation. There is no event notification this way either.
Does anyone know of a better way than my workaround?
Therefore, I am calculating it myself as the following DataTable events occur: ColumnChanged (only if it is the total column), RowChanged (only if it is an DataRowAction.Add change), and RowDeleted. I am using the following code:
Code:
tblSpecification.Compute("SUM(Total)", "fkCategory <> " + this.BuilderSiteCosts);
The problem is that the RowChanged event occurs BEFORE the new row is actually added to the DataTable so the result of the Compute method is less the added row.
All other events work fine. RowDeleted occurs after the row is actually removed from the DataTable, ColumnChanged occurs after the column values are actually changed.
My workaround is to add the value of the added row onto the result of Compute only for that event.
I've also tried using an aggregate column such as:
Code:
new DataColumn("BaseTotal", typeof(double), "SUM(Total)")
Does anyone know of a better way than my workaround?