I using XamWebGrid 10.1 with ColumnLayout and Summaries inside. In each column layout I am showing Countries; i.e. USA, Canada, Mexico. What I would like for the summary in each is to say "Total for USA", "Total for Canada", "Total for Mexico". It seems the only way to get access to the summary is through a converter, but when it converts there is no access to and of the Grid properties. Is there anyway to achieve this?
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((value as SummaryResult).SummaryDefinition.ColumnKey == "Country") {
//here is where I was trying to doing something special } else { return (value as SummaryResult).Value as String; } }
Just to be sure about what you are asking.
Are you using group by on the column and inside a group looking to change the caption of the summary
USA
--- DataRow
-- summaryRow Total for USA = X;
Canada
-- data
-- summaryrow Total for Canada = Y
or are you trying to show muliple summaries in single , flat situation?
The SummaryOperand that wraps the summary definition is defined on the columnlayout level. So any changes you make to that object would ultimately change all the summary rows on the same column layout.
so could you explain your set up a little more so I know exactly what you are doing?
I am not using a group by column, my data is already grouped before binding. However my output looks close to what you put. In the Column Layout you'll notice I have a summary for CountryDesc which is just hard coded as Totals, but I would like a way for that to be specific so when it shows
--DataRow --ColumnLayoutRow USA --DataRow $500 --DataRow $1500 --SummaryRow for ColumnLayout: Total for USA $2000--DataRow --ColumnLayoutRow Canada --DataRow $4000 --DataRow $2000 --SummaryRow for ColumnLayout: Total for Canada $6000--DataRow
below is a sample of what I am doing. I set the DataContext of the page to my datawrapper.
public class datawrapper{ public List<data> ReportData {get; set;}}
public class data{ public List<data> DetailData {get; set;}
public string CountryDesc {get; set;} public decimal Sales {get; set;}}
XAML:
<igGrid:XamWebGrid x:Name="dgSummary" Margin="10,0" ItemsSource="{Binding ReportData}" AutoGenerateColumns="False"> <igGrid:XamWebGrid.SummaryRowSettings> <igGrid:SummaryRowSettings AllowSummaryRow="Bottom"></igGrid:SummaryRowSettings> </igGrid:XamWebGrid.SummaryRowSettings> <igGrid:XamWebGrid.Columns> <igGrid:TextCOlumn Key=""/> <igGrid:ColumnLayout Key="DetailData" HeaderVisibility="Collapsed" IsAlternateRowsEnabled="True"> <igGrid:ColumnLayout.SummaryRowSettings> <igGrid:SummaryRowSettingsOverride Style="{StaticResource CustomSummaryStyle}" AllowSummaryRow="Bottom"></igGrid:SummaryRowSettingsOverride> </igGrid:ColumnLayout.SummaryRowSettings> <igGrid:ColumnLayout.Columns> <igGrid:TextColumn Key="CountryDesc" Width="185"> <igGrid:TextColumn.SummaryColumnSettings> <igGrid:SummaryColumnSettings> <igGrid:SummaryColumnSettings.SummaryOperands> <igGrid:SumSummaryOperand IsApplied="True" RowDisplayLabel="Totals"></igGrid:SumSummaryOperand> </igGrid:SummaryColumnSettings.SummaryOperands> </igGrid:SummaryColumnSettings> </igGrid:TextColumn.SummaryColumnSettings> </igGrid:TextColumn> <igGrid:TextColumn Key="Sales" FormatString="{}{0:#,##0;(#,##0);0}" Width="100" HorizontalContentAlignment="Right"> <igGrid:TextColumn.SummaryColumnSettings> <igGrid:SummaryColumnSettings> <igGrid:SummaryColumnSettings.SummaryOperands> <igGrid:SumSummaryOperand IsApplied="True" FormatString="{}{0:#,##0;(#,##0);0}" RowDisplayLabel=" "></igGrid:SumSummaryOperand> </igGrid:SummaryColumnSettings.SummaryOperands> </igGrid:SummaryColumnSettings> </igGrid:TextColumn.SummaryColumnSettings> </igGrid:TextColumn> </igGrid:ColumnLayout.Columns> </igGrid:ColumnLayout> </igGrid:ColumnLayout.Columns> </igGrid:ColumnLayout> </igGrid:XamWebGrid.Columns> </igGrid:XamWebGrid>
I found a solution to my problem. I found this this blog about creating custom summary operands. Once I access to the data I was able to use a Linq Express to return the correct output.
http://blogs.infragistics.com/blogs/devin_rader/archive/2010/01/07/creating-custom-summery-operands.aspx