Skip to content

Commit d64eabc

Browse files
Added code snippets
1 parent 1c65146 commit d64eabc

File tree

1 file changed

+227
-0
lines changed

1 file changed

+227
-0
lines changed

MAUI/DataGrid/summaries.md

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,82 @@ SfDataGrid supports displaying both column summaries and title summaries simulta
375375

376376
In the code snippet below, DataGridSummaryRow.TitleColumnCount is set as 2, and [DataGridSummaryRow.Title](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridSummaryRow.html#Syncfusion_Maui_DataGrid_DataGridSummaryRow_Title) is defined along with summary columns.
377377

378+
{% tabs %}
379+
{% highlight xaml %}
380+
<dataGrid:SfDataGrid x:Name="dataGrid"
381+
ItemsSource="{Binding OrderItems}"
382+
AutoGenerateColumnsMode="None"
383+
SelectionMode="Single"
384+
GridLinesVisibility="Both"
385+
HeaderGridLinesVisibility="Both"
386+
AllowGroupExpandCollapse="True">
387+
388+
<dataGrid:SfDataGrid.Columns>
389+
<dataGrid:DataGridTextColumn MappingName="OrderId"
390+
HeaderText="Order ID" />
391+
<dataGrid:DataGridTextColumn MappingName="CustomerId"
392+
HeaderText="Customer ID"
393+
ColumnWidthMode="Auto" />
394+
<dataGrid:DataGridTextColumn MappingName="CustomerName"
395+
HeaderText="Customer Name"
396+
ColumnWidthMode="Auto" />
397+
</dataGrid:SfDataGrid.Columns>
398+
399+
<dataGrid:SfDataGrid.GroupColumnDescriptions>
400+
<dataGrid:GroupColumnDescription ColumnName="CustomerId" />
401+
</dataGrid:SfDataGrid.GroupColumnDescriptions>
402+
403+
<dataGrid:SfDataGrid.CaptionSummaryRow>
404+
<dataGrid:DataGridSummaryRow Title="{}{ColumnName}Customer ID : {Key} - {ProductCount} Items" TitleColumnCount="2">
405+
<dataGrid:DataGridSummaryRow.SummaryColumns>
406+
<dataGrid:DataGridSummaryColumn Name="CustomerName"
407+
MappingName="CustomerName"
408+
Format="{}{Count}"
409+
SummaryType="CountAggregate" />
410+
<dataGrid:DataGridSummaryColumn Name="ProductCount"
411+
MappingName="ProductName"
412+
Format="{}{Count}"
413+
SummaryType="CountAggregate" />
414+
</dataGrid:DataGridSummaryRow.SummaryColumns>
415+
</dataGrid:DataGridSummaryRow>
416+
</dataGrid:SfDataGrid.CaptionSummaryRow>
417+
418+
</dataGrid:SfDataGrid>
419+
420+
{% endhighlight %}
421+
{% endtabs %}
422+
423+
{% tabs %}
424+
{% highlight c# %}
425+
426+
GridSummaryRow captionSummaryRow = new GridSummaryRow()
427+
{
428+
Title = "Customer ID : {Key} - {ProductCount} Items",
429+
TitleColumnCount = 2,
430+
SummaryColumns = new ObservableCollection<ISummaryColumn>()
431+
{
432+
new GridSummaryColumn()
433+
{
434+
Name = "CustomerName",
435+
MappingName = "CustomerName",
436+
SummaryType = SummaryType.CountAggregate,
437+
Format = "{Count}"
438+
},
439+
new GridSummaryColumn()
440+
{
441+
Name = "ProductCount",
442+
MappingName = "ProductName",
443+
SummaryType = SummaryType.CountAggregate,
444+
Format = "{Count}"
445+
}
446+
}
447+
};
448+
449+
dataGrid.CaptionSummaryRow = captionSummaryRow;
450+
451+
{% endhighlight %}
452+
{% endtabs %}
453+
378454
### Limitations
379455

380456
The following are the limitations of displaying column summary along with title at same time for DataGridSummaryRow:
@@ -680,6 +756,69 @@ SfDataGrid supports displaying both column summaries and title summaries simulta
680756

681757
In the code snippet below, DataGridSummaryRow.TitleColumnCount is set as 2, and [DataGridSummaryRow.Title](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridSummaryRow.html#Syncfusion_Maui_DataGrid_DataGridSummaryRow_Title) is defined along with summary columns.
682758

759+
{% tabs %}
760+
{% highlight xaml %}
761+
<dataGrid:SfDataGrid x:Name="dataGrid"
762+
ItemsSource="{Binding OrderItems}"
763+
AutoGenerateColumnsMode="None"
764+
SelectionMode="Single"
765+
GridLinesVisibility="Both"
766+
HeaderGridLinesVisibility="Both"
767+
AllowGroupExpandCollapse="True">
768+
769+
<dataGrid:SfDataGrid.Columns>
770+
<dataGrid:DataGridTextColumn MappingName="OrderId"
771+
HeaderText="Order ID" />
772+
<dataGrid:DataGridTextColumn MappingName="CustomerId"
773+
HeaderText="Customer ID" />
774+
<dataGrid:DataGridTextColumn MappingName="CustomerName"
775+
HeaderText="Customer Name"
776+
ColumnWidthMode="Auto" />
777+
</dataGrid:SfDataGrid.Columns>
778+
779+
<dataGrid:SfDataGrid.GroupColumnDescriptions>
780+
<dataGrid:GroupColumnDescription ColumnName="CustomerId" />
781+
</dataGrid:SfDataGrid.GroupColumnDescriptions>
782+
783+
<dataGrid:SfDataGrid.GroupSummaryRows>
784+
<dataGrid:DataGridSummaryRow Title="Total Price: {PriceAmount} for {ProductCount} Products" TitleColumnCount="2">
785+
<dataGrid:DataGridSummaryRow.SummaryColumns>
786+
<dataGrid:DataGridSummaryColumn Name="CustomerName"
787+
MappingName="CustomerName"
788+
Format="{}{Count}"
789+
SummaryType="CountAggregate" />
790+
</dataGrid:DataGridSummaryRow.SummaryColumns>
791+
</dataGrid:DataGridSummaryRow>
792+
</dataGrid:SfDataGrid.GroupSummaryRows>
793+
794+
</dataGrid:SfDataGrid>
795+
{% endhighlight %}
796+
{% endtabs %}
797+
798+
{% tabs %}
799+
{% highlight c# %}
800+
801+
GridSummaryRow groupSummaryRow = new GridSummaryRow()
802+
{
803+
Title = "Total Price: {PriceAmount} for {ProductCount} Products",
804+
TitleColumnCount = 2,
805+
SummaryColumns = new ObservableCollection<ISummaryColumn>()
806+
{
807+
new GridSummaryColumn()
808+
{
809+
Name = "CustomerName",
810+
MappingName = "CustomerName",
811+
SummaryType = SummaryType.CountAggregate,
812+
Format = "{Count}"
813+
}
814+
}
815+
};
816+
817+
dataGrid.GroupSummaryRows.Add(groupSummaryRow);
818+
819+
{% endhighlight %}
820+
{% endtabs %}
821+
683822
### Limitations
684823

685824
The following are the limitations of displaying column summary along with title at same time for DataGridSummaryRow:
@@ -1141,6 +1280,94 @@ SfDataGrid supports displaying both column summaries and title summaries simulta
11411280

11421281
In the code snippet below, DataGridTableSummaryRow.TitleColumnCount is set as 2, and [DataGridTableSummaryRow.Title](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.DataGrid.DataGridSummaryRow.html#Syncfusion_Maui_DataGrid_DataGridSummaryRow_Title) is defined along with summary columns.
11431282

1283+
{% tabs %}
1284+
{% highlight xaml %}
1285+
<dataGrid:SfDataGrid x:Name="dataGrid"
1286+
ItemsSource="{Binding OrderItems}"
1287+
AutoGenerateColumnsMode="None"
1288+
SelectionMode="Single"
1289+
GridLinesVisibility="Both"
1290+
HeaderGridLinesVisibility="Both">
1291+
1292+
<dataGrid:SfDataGrid.Columns>
1293+
<dataGrid:DataGridTextColumn MappingName="OrderId"
1294+
HeaderText="Order ID" />
1295+
<dataGrid:DataGridTextColumn MappingName="CustomerId"
1296+
HeaderText="Customer ID" />
1297+
<dataGrid:DataGridTextColumn MappingName="CustomerName"
1298+
HeaderText="Customer Name"
1299+
ColumnWidthMode="Auto" />
1300+
</dataGrid:SfDataGrid.Columns>
1301+
1302+
<dataGrid:SfDataGrid.TableSummaryRows>
1303+
<dataGrid:DataGridTableSummaryRow Title="Total Price: {PriceAmount} for {ProductCount} products" TitleColumnCount="2" Position="Top">
1304+
<dataGrid:DataGridTableSummaryRow.SummaryColumns>
1305+
<dataGrid:DataGridSummaryColumn Name="CustomerName"
1306+
MappingName="CustomerName"
1307+
Format="{}{Count}"
1308+
SummaryType="CountAggregate" />
1309+
</dataGrid:DataGridTableSummaryRow.SummaryColumns>
1310+
</dataGrid:DataGridTableSummaryRow>
1311+
<dataGrid:DataGridTableSummaryRow Title="Total Price: {PriceAmount} for {ProductCount} products" TitleColumnCount="2" Position="Bottom">
1312+
<dataGrid:DataGridTableSummaryRow.SummaryColumns>
1313+
<dataGrid:DataGridSummaryColumn Name="CustomerName"
1314+
MappingName="CustomerName"
1315+
Format="{}{Count}"
1316+
SummaryType="CountAggregate" />
1317+
</dataGrid:DataGridTableSummaryRow.SummaryColumns>
1318+
</dataGrid:DataGridTableSummaryRow>
1319+
</dataGrid:SfDataGrid.TableSummaryRows>
1320+
1321+
</dataGrid:SfDataGrid>
1322+
{% endhighlight %}
1323+
{% endtabs %}
1324+
1325+
{% tabs %}
1326+
{% highlight c# %}
1327+
1328+
GridTableSummaryRow topSummaryRow = new GridTableSummaryRow()
1329+
{
1330+
ShowSummaryInRow = false,
1331+
Position = TableSummaryRowPosition.Top,
1332+
Title = "Total Price : {PriceAmount} for {ProductCount} products",
1333+
TitleColumnCount = 2,
1334+
SummaryColumns = new ObservableCollection<ISummaryColumn>()
1335+
{
1336+
new GridSummaryColumn()
1337+
{
1338+
Name = "CustomerName",
1339+
MappingName = "CustomerName",
1340+
SummaryType = SummaryType.CountAggregate,
1341+
Format = "{Count:d}"
1342+
}
1343+
}
1344+
};
1345+
1346+
dataGrid.TableSummaryRows.Add(topSummaryRow);
1347+
1348+
GridTableSummaryRow bottomSummaryRow = new GridTableSummaryRow()
1349+
{
1350+
ShowSummaryInRow = false,
1351+
Position = TableSummaryRowPosition.Bottom,
1352+
Title = "Total Price : {PriceAmount} for {ProductCount} products",
1353+
TitleColumnCount = 2,
1354+
SummaryColumns = new ObservableCollection<ISummaryColumn>()
1355+
{
1356+
new GridSummaryColumn()
1357+
{
1358+
Name = "CustomerName",
1359+
MappingName = "CustomerName",
1360+
SummaryType = SummaryType.CountAggregate,
1361+
Format = "{Count:d}"
1362+
}
1363+
}
1364+
};
1365+
1366+
dataGrid.TableSummaryRows.Add(bottomSummaryRow);
1367+
1368+
{% endhighlight %}
1369+
{% endtabs %}
1370+
11441371
### Limitations
11451372

11461373
The following are the limitations of displaying column summary along with title at same time for DataGridTableSummaryRow:

0 commit comments

Comments
 (0)