When I know the name of column (MyName) it is working when defined like this:
<syncfusion:SfDataGrid.TableSummaryRows> <syncfusion:GridTableSummaryRow Position="Top" ShowSummaryInRow="False"> <syncfusion:GridTableSummaryRow.SummaryColumns> <syncfusion:GridSummaryColumn Name="CountIssues" Format="'{Count:d}(Count)'" MappingName="MyName" SummaryType="CountAggregate" /> </syncfusion:GridTableSummaryRow.SummaryColumns> </syncfusion:GridTableSummaryRow> </syncfusion:SfDataGrid.TableSummaryRows>
How do I have to define when I use the grid with autogenerated columns only? I do not know the name of the columns before. Is it possible to bind to the first column always?
|
//Event subscription
dataGrid.AutoGeneratingColumn += dataGrid_AutoGeneratingColumn;
bool isFirstColumn = true;
//Event customization
private void dataGrid_AutoGeneratingColumn(object sender, Syncfusion.UI.Xaml.Grid.AutoGeneratingColumnArgs e)
{
if (isFirstColumn)
{
isFirstColumn = false;
this.dataGrid.TableSummaryRows.Add(new GridTableSummaryRow()
{
ShowSummaryInRow = false,
SummaryColumns = new ObservableCollection<ISummaryColumn>()
{
new GridSummaryColumn()
{
Name = "Sum",
MappingName=e.Column.MappingName,
SummaryType= SummaryType.Int32Aggregate,
Format="Total UnitPrice : {Sum:c}"
}
}
});
}
} |
Thank you.
This is working so far.
As I'm going to load different collections into the grid, I'm wondering what would be the best event to reset isFirstColumn to true again?
ItemsSourceChanged seems to fit. Would you recommend another event?