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

Problema in TableSummaryRows when I try sum in GridSummaryColumn

Hi,

I have the code below:

 <syncfusion:SfDataGrid x:Name="dataGrid" Grid.Row="2" AutoGenerateColumns="False" DefaultColumnWidth="150" ScrollingMode="Line">
                    <syncfusion:SfDataGrid.Columns>
                        <syncfusion:GridTextColumn MappingName="Estabelecimento" HeaderText="Nome Estabeleciomento" HeaderTextAlignment="Center" ColumnSizer="LastColumnFill" />
                        <syncfusion:GridTextColumn MappingName="ValorProcedimento" HeaderText="Valor Procedimento" HeaderTextAlignment="Center" ColumnSizer="LastColumnFill"  />
                        <syncfusion:GridTextColumn MappingName="ValorComissao" HeaderText="Valor Comissão" HeaderTextAlignment="Center" ColumnSizer="LastColumnFill"  />
                    </syncfusion:SfDataGrid.Columns>
                    <syncfusion:SfDataGrid.TableSummaryRows>
                         <syncfusion:GridTableSummaryRow Title="Total: {TotalSalary} e procedimentos: {TotalCount}" ShowSummaryInRow="True">
                            <syncfusion:GridTableSummaryRow.SummaryColumns>
                                <syncfusion:GridSummaryColumn Name="TotalSalary"
                                          Format="{}{Sum:c}"
                                          MappingName="ValorComissao"
                                          SummaryType="DoubleAggregate" />
                                <syncfusion:GridSummaryColumn Name="TotalCount"
                                                  Format="{}{Count}"
                                                  MappingName="ValorProcedimento"
                                                  SummaryType="CountAggregate" />
                            </syncfusion:GridTableSummaryRow.SummaryColumns>
                        </syncfusion:GridTableSummaryRow>
                    </syncfusion:SfDataGrid.TableSummaryRows>
                </syncfusion:SfDataGrid>   

Using this code and one ModelView class, the result of my sum is 0 (zero). My impressions is that once o SfDatagrid is rendering in my page, the sum is not fired because  the data collection not returned from my server. Really in execution of page, the grid is view but before only seconds, the data from my server is visible, updated my SfDatagrid.

I need help to resolve this.

Tks



5 Replies

KK Karthikraja Kalaimani Syncfusion Team January 10, 2020 01:55 PM UTC

Hi Henrique,

Thank you for contacting Syncfusion support.

We have checked the reported issue “Table Summary sum is showing as zero” and we are unable to reproduce the issue in our end and it is working fine as expected. We have attached the tested sample for your reference.  In that sample we have loaded the data to SfDataGrid by asynchronously. So you've got to wait a few seconds to get data from server. Before launching the app, make sure that you have to allow Internet connection. 
 
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGrid_Demo1117120820.zip


Video link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Video_150523-1666860625.zip

Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us back.

Regards,
Karthik Raja





HE Henrique January 13, 2020 11:18 PM UTC

Hi,

I tried using the code example sended to me, but I have the same problem. Below my code and comment.

The part of code to populate grid:

 HistComissaoViewModel _tmpview = new HistComissaoViewModel(pckEmpresas.Items[pckEmpresas.SelectedIndex]);

ObservableCollection<e_Beauty.JSON.HistComissoes> records = _tmpview.HistComissoesList;

dataGrid.ItemsSource = records;

Below my class to get informations from Firebase database using ModelView:

public class HistComissaoViewModel : ObservableObject
    {
        public string _empresa;

        public HistComissaoViewModel(string empresa) : base(listenCultureChanges: true)
        {
            _empresa = empresa;

            LoadData();
        }

        public ObservableCollection<e_Beauty.JSON.HistComissoes> HistComissoesList { get; set; } = new ObservableCollection<e_Beauty.JSON.HistComissoes>();

        protected override void OnCultureChanged(CultureInfo culture)
        {
            LoadData();
        }

        private async void LoadData()
        {
            HistComissoesList.Clear();

            HistComissaoDB _db = new HistComissaoDB() { UID = App.UID, Empresa = _empresa };

            List<e_Beauty.JSON.HistComissoes> _procedimentos = await _db.GetHistComissaoEmpresaDay();
          
            foreach (var item in _procedimentos)
            {
                e_Beauty.JSON.HistComissoes _tmp = new e_Beauty.JSON.HistComissoes();

                _tmp.Procedimento = item.Procedimento;
                _tmp.Estabelecimento = item.Estabelecimento;
                _tmp.ValorProcedimento = item.ValorProcedimento;
                _tmp.ValorComissao = item.ValorComissao;
                _tmp.ValorComissaoGrid = (Double)item.ValorComissao;
                
                HistComissoesList.Add(_tmp);
            }
        }
    }
}

Using the demonstrate code I have the problem  again.

When I use the example sended me, the “Table Summary sum" is ok, but the call form is not ModelView. Is a REST call. So, I need your help again, but my modelview is ok when returned informations. I think that problem is in time of Grid component rendering.

Tks a lot.


DB Deepika Balasubramaniyan Syncfusion Team January 14, 2020 12:29 PM UTC

Hi Henrique, 
 
Thanks for your update. 
 
We have checked your code example. Since you have added the data to ItemsSource after some delay, to update the TableSummary for current row data, you need to enable LiveDataUpdateMode setting as AllowSummaryUpdate or AllowDataShaping  to update the summaries in SfDataGrid. For further reference we have added the code example, tested sample and UG link regarding LiveDataUpdateMode. 
 
Code example: 
 
[XAML] 
--- 
 
<sfgrid:SfDataGrid x:Name="sfGrid" 
                           AutoGenerateColumns="False" 
                           LiveDataUpdateMode="AllowSummaryUpdate"> 
 
--- 
 
 
 
 
Please let us know, if this helpful.  
 
 
Regards, 
Deepika. 



HE Henrique January 14, 2020 01:10 PM UTC

Hi,

Tks a lot. Its all ok now.


PK Pradeep Kumar Balakrishnan Syncfusion Team January 15, 2020 05:36 AM UTC

Hi Henrique, 
 
Thanks for the update.  
  
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you.  
 
Regards, 
Pradeep Kumar Balakrishnan 


Loader.
Live Chat Icon For mobile
Up arrow icon