Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
Save/Load Customizations does not work with Custom summary calculators
posted

Easy bug to reproduce.  I'm using the SaveCustomizations/LoadCustomizations API to serialize the grid state and reload it.  Now I've added several custom summary calculators to my grid.

When I Load the state of the grid all of the fields with custom summaries now are using the "Sum" summary calculator instead of the custom one.

I examined the xml output by the SaveCustomizations API and it is serializing the Calculator as "Sum" which is obviously not correct.

This bug makes it impossible to use both features simulataneously.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

igDP:FieldLayout.SummaryDefinitions>

 

 

 

 

 

<igDP:SummaryDefinition SourceFieldName="Oface"

 

 

 

Calculator="{x:Static local:TBAShorts.SelectedSum}"

StringFormat="{}{0:#,#;;0}"/>

 

 

 

 

 

<igDP:SummaryDefinition SourceFieldName="Qty"

Calculator="{x:Static local:TBAShorts.SelectedSum}"

 

 

 

 

StringFormat="{}{0:#,#.##;;0}"/>

 

 

 

 

 

<igDP:SummaryDefinition SourceFieldName="MTG_WACPN"

 

 

 

Calculator="{x:Static local:TBAShorts.SelectedAverage}"

 

 

 

 

StringFormat="{}{0:0.##}"/>

 

 

 

 

 

<igDP:SummaryDefinition SourceFieldName="MTG_WAM"

 

 

 

Calculator="{x:Static local:TBAShorts.SelectedAverage}"

 

 

 

 

StringFormat="{}{0:0.##}"/>

 

 

 

 

 

<igDP:SummaryDefinition SourceFieldName="MTG_WAOLTV"

 

 

 

Calculator="{x:Static local:TBAShorts.SelectedAverage}"

 

 

 

 

StringFormat="{}{0:0.##}"/>

 

 

</

 

 

igDP:FieldLayout.SummaryDefinitions>

 

 

ouput of SaveCustomizations():

&lt;summaries&gt;
        &lt;SummaryDefinition SourceFieldName="Oface" StringFormat="{0:#,#;;0}" Calculator="Sum" /&gt;
        &lt;SummaryDefinition SourceFieldName="Qty" StringFormat="{0:#,#.##;;0}" Calculator="Sum" /&gt;
        &lt;SummaryDefinition SourceFieldName="MTG_WACPN" StringFormat="{0:0.##}" Calculator="Sum" /&gt;
        &lt;SummaryDefinition SourceFieldName="MTG_WAM" StringFormat="{0:0.##}" Calculator="Sum" /&gt;
        &lt;SummaryDefinition SourceFieldName="MTG_WAOLTV" StringFormat="{0:0.##}" Calculator="Sum" /&gt;

&lt;/summaries&gt;

 

 

 

My custom calculators, which derive from SumSummaryCalculator

 

 

 

 

 

 

 

 

 

 

 

 

 

 

public class SelectedWeightedAverageCalculator :

SumSummaryCalculator

{

 

 

 

public override void Aggregate(object dataValue, SummaryResult summaryResult, Record

record)

{

 

 

 

if (dataValue is decimal

)

{

 

 

 

TBAShortAllocation item = (TBAShortAllocation)((DataRecord

)record).DataItem;

 

 

 

if

(item.IsSelected)

{

 

 

 

base.Aggregate((decimal

)dataValue * item.Weight, summaryResult, record);

}

}

}

}

 

 

 

public class SelectedSumCalculator :

SumSummaryCalculator

{

 

 

 

public override void Aggregate(object dataValue, SummaryResult summaryResult, Record

record)

{

 

 

 

TBAShortAllocation item = (TBAShortAllocation)((DataRecord

)record).DataItem;

 

 

 

if

(item.IsSelected)

{

 

 

 

base

.Aggregate(dataValue, summaryResult, record);

Parents Reply Children