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. Image for the cookie policy date

Number of records in a SfDataGrid

Hi,

I'm wondering if it should be possible on an SfDataGrid to show, in some manner, to the user the number of the total records the grid is mananing together with the number of filtered ones, if any.
Sometimes in fact it should be important to quickly know how many records are shown and/or filtered.
Do you have such a functionality?
Have you any idea if it can be implemented with the current version library ?

Silvio S.

3 Replies

SR Sivakumar R Syncfusion Team January 16, 2017 05:45 PM UTC

Hi Silvio, 
 
You can show the number records count using table summary. You can show table summary either top or bottom of SfDataGrid. 
 
Thanks, 
Sivakumar 



JV Johan Visser February 16, 2024 10:47 AM UTC

I am looking for the same functionality.

I looked at the 2 links you provided.

The problem is that I don't know what columns are in the grid. That is up to the user, he can add his own queries.

I just want a record counter that counts the number of records in the grid without knowing what data is in the grid.


Do you have an example for this scenario?




SB Sweatha Bharathi Syncfusion Team February 19, 2024 01:35 PM UTC

Hi Johan Visser,


We have analyzed your query. Your requirement to display the number of records in the DataGrid without knowing the data , can be achieved by accessing the Records Count property of the DataGrid. We have implemented a solution to show the record count in the TableSummaryRows template, using a TextBlock and binding a converter to display the records count.


Kindly refer to the code snippet below,
and let us know if you have any further concerns regarding this.


Code Snippet:



<Window.Resources>

    <local:TableSummaryRowConverter x:Key="summaryConverter"/>

</Window.Resources>


<syncfusion:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding Orders}" AutoGenerateColumns="True">

     <syncfusion:SfDataGrid.TableSummaryRows>

         <syncfusion:GridTableSummaryRow Title="Total Record" ShowSummaryInRow="True">

             <syncfusion:GridSummaryRow.TitleTemplate>

                 <DataTemplate>

                     <TextBlock  Text="{Binding Converter={StaticResource summaryConverter}, ConverterParameter= {x:Reference Name= dataGrid}}"></TextBlock>

                 </DataTemplate>

             </syncfusion:GridSummaryRow.TitleTemplate>

         </syncfusion:GridTableSummaryRow>

     </syncfusion:SfDataGrid.TableSummaryRows>

 </syncfusion:SfDataGrid>

 

 

 

/// Converter Code

 

public class TableSummaryRowConverter : IValueConverter

 {

     public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

     {

 

         var count = (parameter as SfDataGrid).View.Records.Count;

         return "Total Records : "  + count.ToString();

     }

 

     public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

     {

         return null;

     }

 }

 



UG Link : https://help.syncfusion.com/wpf/datagrid/summaries?cs-save-lang=1&cs-lang=csharp#table-summary-template


Loader.
Up arrow icon