This is a migrated thread and some comments may be shown as answers.

Summary row item for editable checkbox column

2 Answers 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zygmunt
Top achievements
Rank 1
Iron
Iron
Iron
Zygmunt asked on 14 Apr 2020, 07:26 AM

Hi
I have RadGridView with editable checkbox column. I created custom summary row item which code i presented below.

public class CheckedRowsSummaryItem : GridViewSummaryItem
    {
        public CheckedRowsSummaryItem(string name, string formatString, GridAggregateFunction aggregate)
            : base(name, formatString, aggregate)
        { }
        public override object Evaluate(IHierarchicalRow row)
        {
            int count = 0;
            foreach (GridViewRowInfo childRow in row.ChildRows)
            {
                try
                {
                    if ((bool)childRow.Cells["chkBoxKol"].Value)
                    {
                        count++;
                    }
                }
                catch { }
            }
            return count;
        }
    }

 

My problem is that when I change the chceckbox state my custom row summary for the column is not refreshed until I change current row or current cell. I tried to set IsCurrent properity on false or rise EndEdit() method for the grid in CellBeginEdit event but these solutions not worked. How could I programmatically make my summary refresh to avoid changing current column by the user?

 

All the best

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Apr 2020, 12:06 PM

Hello, Zygmunt,

According to the provided information, it is not clear how the GridViewCheckBoxColumn is setup on your end. However, I would recommend you to set its EditMode property to OnValueChange. Thus, you will ensure that as soon as you toggle the checkbox, the value will be committed to the associated DataBoundItem

The EditMode property controls when the value of the editor will be submitted to the cell. By default, the current behavior is kept (OnValidate) and the value will be submitted only when the current cell changes or the grid looses focus. The new value (OnValueChange) will submit the value immediately after the editor value changes.

Thus, your custom summary item is expected to calculate the value as expected.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Massoud
Top achievements
Rank 1
commented on 05 May 2021, 11:37 AM

I've set the EditMode for a check box column, but the summary item is not updated upon changing the check state of the column in any row. Could you please let me know what the problem is it ?
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 May 2021, 10:33 AM
Hello, Zygmunt,

By using the provided code snippet in your initial post, I have prepared a sample project which result is illustrated in the attached gif file. Please give the sample project a try and see how it works on your end.

In case you are still experiencing any problems with implementing such a behavior in your project, please give is more details about the exact setup that you have and how it differs from my sample project. Once we replicate the undesired behavior on our end, we would be able to investigate the precise case and provide further assistance. 

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
GridView
Asked by
Zygmunt
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or