We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Unable to find the TableSummaryRow index in SfDataGrid's TableSummaryRows for style customisation

Thread ID:





119420 Jun 18,2015 09:12 AM UTC Jun 22,2015 07:02 AM UTC WPF 3
Tags: SfDataGrid
Anas El Hallabi
Asked On June 18, 2015 09:12 AM UTC


I'm trying to apply a different style on the last TableSummaryRow. For that, I used the TableSummaryRowStyleSelector="{StaticResource tableSummaryRowStyleSelector}"  property on the SfDataGrid. 
In the "SelectStyle(object item, DependencyObject container)" method in my style selector class, I am unable to get the information about the row position of the current row in SfDataGrid's TableSummaryRows: container is a Syncfusion.UI.Xaml.Grid.TableSummaryRowControl and item is a Syncfusion.UI.Xaml.Grid.SpannedDataRow

Is there a way to get that info ?

Many Thanks,

Farjana Parveen Ayubb [Syncfusion]
Replied On June 19, 2015 11:32 AM UTC

Hi Anas,

Thank you for contacting Syncfusion support.

We analyzed your query and you can achieve your requirement “Customize the TableSummaryRowStyle based on the TableSummary row index” by getting the row index from the SpannedDataRow in StyleSeletor.

Please refer the code example and sample in the following location:

Code Snippet (XAML):

  <syncfusion:SfDataGrid x:Name="sfdatagrid" 



                               TableSummaryRowStyleSelector="{StaticResource tableSummaryStyleSelector}"
                               ItemsSource="{Binding Path=Products}" >

Code Snippet(C# - StyleSelector):

class TableSummaryStyleSelector : StyleSelector


        public override Style SelectStyle(object item, DependencyObject container)


            var data = item as SpannedDataRow;

            var index = data.RowIndex;

            if (index == 1)

                return App.Current.Resources["TableSummaryStyle1"] as Style;

            return App.Current.Resources["TableSummaryStyle2"] as Style;


Sample Location: TableSummaryRowStyle

If your requirement is differ from this could you please share the exact requirement that will help us to provide the solution in better way.


Farjana Parveen A

Anas El Hallabi
Replied On June 19, 2015 11:56 AM UTC

Hello Farjana Parveen A,

Thanks you for your answer.
Actually, I was aware of the RowIndex property of the spannedDataRow but in my situation, i don't know how many TableSummaryRows are actually beeing displayed in the sfdatagrid.
Thanks to debugger, i noticed that SpannedDataRow had an internal property "DataGrid" which refer to the grid. Using reflexion i managed to get it and so, the TableSummaryRows property as in code below:

var dataGrid = typeof(SpannedDataRow).GetProperty("DataGrid", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(tItem) as SfDataGrid;

var currentSummaryRow = (tItem.RowData as Syncfusion.Data.SummaryRecordEntry).SummaryRow as GridTableSummaryRow;

if (dataGrid != null && dataGrid.TableSummaryRows.Any() && dataGrid.TableSummaryRows.Last() == currentSummaryRow)
        isTheLastDisplayedRow = true;

This made the trick, thank you again for your support.


Saranya CJ [Syncfusion]
Replied On June 22, 2015 07:02 AM UTC

Hi Anas,
Thank you for your update. Please let us know if you require any other assistance.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon