http://blogs.infragistics.com/wpf/articles/creating-a-custom-summary-for-the-xamdatagrid.aspx
My first question is about this line of code in the above cited article:
SummaryCalculator.Register(Summary);
The article cited above says
"This can be achieved by not registering our summary like demonstrated above, but by associating a specific summary definition with a given column:"
"..the developer may want to show their custom summary on a specific field without placing it on every column. "
Emphisis on "not" and "every" is mine...........The article implies that there are two mutually exclusive methods for registering the summaries class ( second method cited in q2 below). When I follow the example I see no summaries at all however the second line quoted above leads me to think that following the example should not have the effect of doing nothing, but should instead display summaries on every column. Question: So when we do register the summary as shown in the article, what is accomplished? Is there additional code that needs to be added to make the article useful, or perhaps some xaml that is expected?
Question 2:
When i use this code I am able to get a summary row to display:
SummaryDefinition myTopSalesPersonFormula = new SummaryDefinition(); myTopSalesPersonFormula.SourceFieldName = "SalesYTD"; myTopSalesPersonFormula.Calculator = Summary; this.xamDataGrid1.FieldLayouts[0].SummaryDefinitions.Add(myTopSalesPersonFormula);
However, unlike the example, I get two rows of totals. I really only need one row, how do I remove the second row? I assume the second row is a subtotal row but I dont know that for sure and when I search for subtotals I find nothing relevent.
Question 3:
My specific question is how to remove the equal sign in front of the displayed total..... but more generally I would like to know what xaml (if any) is required to work with the code behind that is shown in the article. When I use the xaml that is shown in the feature explorer i.e.
<igDP:SummaryDefinition Key="Coupon" SourceFieldName="Coupon" Calculator="Sum">
I get yet a third row of of totals..................
Stefan,
In the xaml above please remove this line:
<igDP:Field Name="Age" Label="Age"></igDP:Field>
I was experimenting with your example and I added that. It is not relevent to the reply I posted above.
Hi Sefan, Thank you for your help. You found the problem but your code does not illustrate a solution. Please use the following in MainWindow.xaml to illustrate:
<Window x:Class="CustomSummaryCalculator.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igWindows="http://infragistics.com/Windows" Title="MainWindow" Height="350" Width="525" xmlns:igDP="http://infragistics.com/DataPresenter"> <Grid> <igWindows:XamTabControl TabItemCloseButtonVisibility="Hidden"> <igWindows:TabItemEx Header="Tab 1"> <igDP:XamDataGrid Loaded="xamDataGrid1_Loaded" Name="xamDataGrid1" VerticalAlignment="Top"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="Name" Label="Name"></igDP:Field> <igDP:Field Name="Salary" Label="Salary"></igDP:Field> <igDP:Field Name="Age" Label="Age"></igDP:Field> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </igWindows:TabItemEx> <igWindows:TabItemEx Header="Tab 2"> <TextBlock Text="This is tab 2"></TextBlock> </igWindows:TabItemEx> </igWindows:XamTabControl> </Grid></Window>
I think you have to unwire the load event inside the handler.
Hi again,
As far as I understand you, you want to have a summary row on project start, but you don’t want to have a dropdown and allow user to make summaries. If that so, I created a sample project for you showing how to do this. Please let me know if this is what you are trying to achieve or I have misunderstood you in some way.
Looking forward for your reply.
Hi Stefan,
I do not want to display the summaries dropdown, I want the summary row to always appear (but only one row ). I am unable to determine how to accomplish this. Sorry for being so dense will you kindly assist me. Sorry but I dont know how to format code:<code>void PositionView_Loaded(object sender, RoutedEventArgs e) { // Add summary row expressions to FWPGrid.
PresentablePosition p = new PresentablePosition(); FWPGridSummary summary; SummaryDefinition def; List<KeyValuePair<string,Func<IList<PresentablePosition>, decimal>>> properties = new List<KeyValuePair<string,Func<IList<PresentablePosition>, decimal>>>(); properties.Add(new KeyValuePair<string,Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.OFace_Net), (x) => x.Sum(y => y.OFace_Net))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Qty_Net), (x) => x.Sum(y => y.Qty_Net))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.OFace_Avail), (x) => x.Sum(y => y.OFace_Avail))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Qty_Avail), (x) => x.Sum(y => y.Qty_Avail))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.WAC), (x) => Convert.ToDecimal(x.Sum(y => y.WAC)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.WAM), (x) => Convert.ToDecimal(x.Sum(y => y.WAM)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Avg_LTV), (x) => Convert.ToDecimal(x.Sum(y => y.Avg_LTV)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.FICO), (x) => Convert.ToDecimal(x.Sum(y => y.FICO)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.WALA), (x) => Convert.ToDecimal(x.Sum(y => y.WALA)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.CPR1m), (x) => Convert.ToDecimal(x.Average(y => y.CPR1m)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.CPR3m), (x) => Convert.ToDecimal(x.Average(y => y.CPR3m)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.CPR6m), (x) => Convert.ToDecimal(x.Average(y => y.CPR6m)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.MedAvgLoanSize), (x) => Convert.ToDecimal(x.Sum(y => y.MedAvgLoanSize)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.MaxAvgLoanSize), (x) => Convert.ToDecimal(x.Sum(y => y.MaxAvgLoanSize)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Duration), (x) => Convert.ToDecimal(x.Sum(y => y.Duration)))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Settled_OFace_Net), (x) => x.Sum(y => y.Settled_OFace_Net))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Settled_Qty_Net), (x) => x.Sum(y => y.Settled_Qty_Net))); properties.Add(new KeyValuePair<string, Func<IList<PresentablePosition>, decimal>>(Common.Utilities.PropertyName(() => p.Qty_Pledge), (x) => x.Sum(y => y.Qty_Pledge)));
foreach (KeyValuePair<string, Func<IList<PresentablePosition>, decimal>> kvp in properties) { summary = new FWPGridSummary(ViewModel, kvp.Value, kvp.Key, kvp.Key); def = new SummaryDefinition(); def.SourceFieldName = kvp.Key; def.Calculator = summary; def.Key = kvp.Key; def.StringFormat = "{0:C}"; def.DisplayArea = SummaryDisplayAreas.None | SummaryDisplayAreas.TopFixed; FWPGrid.FieldLayouts[0].SummaryDefinitions.Add(def); } } <igDP:XamDataGrid DataSource="{Binding Path=ViewManager.Items}" Grid.Row="1" AutoFit="True" ScrollingMode="Immediate" Name="FWPGrid" >
<i:Interaction.Triggers> <i:EventTrigger EventName="Sorting"> <galaExtras:EventToCommand Command="{Binding SortCriteriaChangedCommand, Mode=OneWay}" PassEventArgsToCommand="True"></galaExtras:EventToCommand> </i:EventTrigger> </i:Interaction.Triggers> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" Width="Auto" AllowRecordFiltering="False" AllowSummaries="False" SummaryDisplayArea="BottomFixed" SummaryUIType="MultiSelect" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AllowDelete="False" AllowAddNew="False" AllowFieldMoving="WithinLogicalRow" AutoGenerateFields="False" HighlightAlternateRecords="True" MaxSelectedRecords="1"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="IncludeInTotals" Label="Totals"></igDP:Field> <igDP:Field Name="Acct_No" Label="Acct No"/> <igDP:Field Name="CUSIP" Label="CUSIP"/> </code>
Hello,
I am just checking the progress of this issue. Please let me know if I can provide you any further assistance.