how to calculate summary for checked boxes

I want to get total of each column for only the checked rows, my checkbox is (GridCheckBoxColumn)  not ( GridCheckBoxSelectorColumn ) and how to get the total depending on some values in grid.


and I have this tablesummaryrow but when I add the rows the totals didn't update.

how to update the summaries after insert or delete the rows.

Image_8606_1724521148143


2 Replies

SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 26, 2024 06:25 PM UTC

Hi Mohamad,

We are currently implementing your requirement to calculate the TableSummary value based on the check box value. We need some time to validate it, and we will update you further details on or before August 28, 2024.

We appreciate your patience until then. 

Regards,

Sreemon Premkumar M. 



SP Sreemon Premkumar Muthukrishnan Syncfusion Team August 28, 2024 03:28 PM UTC

Hi Mohamad,

Your requirement to update the table summary value based on the checkbox being true can be achieved by using a custom aggregate. However, when updating the table summary value by changing the checkbox at runtime, you need to manually update the value inside the RecordPropertyChanged event. Please find the code snippet below.

Code snippet:

public class CustomAggregate : ISummaryAggregate

{

    public CustomAggregate()

    {

    }

    public double StdDev { get; set; }

    Action<IEnumerable, string, PropertyDescriptor> ISummaryAggregate.CalculateAggregateFunc()

    {

        this.StdDev = 0;

        return (items, property, pd) =>

        {

            var enumerableItems = items;

            if (pd.Name == "StdDev")

            {

                foreach(OrderInfo obj in enumerableItems)

                {

                    if (obj.IsChecked)

                    {

                        this.StdDev += obj.Value2;

                    }

                }

            }

        };

    }

}

Your requirement to update the table summary value when adding a new row can be achieved by setting the LiveDataUpdateMode to AllowSummaryUpdate. Please find the code snippet below.

Code snippet:

sfDataGrid1.LiveDataUpdateMode = LiveDataUpdateMode.AllowSummaryUpdate;


We have prepared a sample based on your requirements, along with a video reference. Please find it in the attachment.

Regards,

Sreemon Premkumar M.


Attachment: SfDataGrid_TableSummary_82c68a1c.zip

Loader.
Up arrow icon