Migrate OnGroupAggregate to OnClientGroupAggregate C1GridView 2025v2 399

Posted by: enrique.pv-ext on 8 July 2026, 8:12 am EST

  • Posted 8 July 2026, 8:12 am EST - Updated 8 July 2026, 8:22 am EST

    Hi,

    Migrate from 2010v1 to 2025v2 399 in ASP.NET WebForms NET Framework 4.8.1.

    Using C1GridView from C1.Web.Wijmo.Controls.48.dll

    There is no OnGroupAggregate server event and C1GroupTextEventArgs class in latest version.

    Replace with the client-side OnClientGroupAggregate event, and set the column’s Aggregate property to Custom.

    I need use the OnClientGroupAggregate client side event:

    C1GridView ID=“C1GridView1” runat=“server”    OnClientGroupAggregate=“OnClientGroupAggregate”

    I have migrated several pages. Another pages, I have any problems about CheckBox column, and codeBehind Session, and variables

    Legacy OnGroupAggregate server event:

    
        protected void BagsGrid_GroupAggregate(object sender, C1.Web.UI.Controls.C1GridView.C1GroupTextEventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = Util.GetCulture();
        decimal sum = 0;
            decimal detractionsSum = 0;
            decimal tollSum = 0;
    
      for (int i = e.StartItemIndex; i <= e.EndItemIndex; i++)
        {
            decimal val = Convert.ToDecimal(((C1GridView)sender).DataKeys[i]["AMOUNT"]);
    
            CheckBox cb = (CheckBox)((C1GridView)sender).Rows[i].Cells[1].FindControl("CheckBoxGrid");
            if (cb.Checked)
            {
                // Sum total amount
                sum += val;
    
                // Sum only toll amount
                tollSum += val;
            }
    
            cb.Attributes.Add("onchange", "recalculateTotal('" + cb.ClientID + "','" + val.ToString() + "','" + Util.GetCulture().Name + "' );");
        }
    
        string sequence = gridTotalSequence.ToString();
        string currencySymbol = "<span>" + Util.GetCulture().NumberFormat.CurrencySymbol + "</span>&nbsp;";
        e.Text += _textsShown[16] + " " + currencySymbol + "<span id=\"GridTotal" + sequence + "\">" + string.Format("{0:N}", sum) + "</span>";
        gridTotalSequence = 2;
    
           Session["PartialWithdrawGridTotal"] = sum.ToString();
        //    HiddenTotal.Value = sum.ToString();
        //    e.Text = string.Format("{0:C}", sum);
        }
    }
    

    My OnClientGroupAggregate client

    
         function BagsGrid_OnClientGroupAggregate(sender, args) {
             console.log("BagsGrid_OnClientGroupAggregate TEST GRIDVIEW: " + args.column.dataIndex);
    
         var CurrencySymbol = '<%= Util.GetCulture().NumberFormat.CurrencySymbol %>';
         let sum = 0;
         let grid = $(sender);
         let data = grid.c1gridview('dataView');
         if (!data) { return; }
    
         var totalItems = data.totalItemCount();
         var startIndex = args.startIndex;
         var endIndex = args.endIndex;
    
         // Clamp indices (equivalente al bucle for del servidor: StartItemIndex → EndItemIndex)
         if (startIndex < 0) { startIndex = 0; }
         if (endIndex >= totalItems) { endIndex = totalItems - 1; }
    
         for (var i = startIndex; i <= endIndex; i++) {
             let row = data.item(i);
             if (!row) { continue; }
    
             let amountText = row[args.column.dataIndex];
             if (amountText) {
                 sum += parseLocaleNumber(amountText);
             }
         }
    
         // Format c0: integer, locale es-ES (without decimal places)
         // Equivalente a string.Format("{0:C}", sum) con cultura es-ES
         let formattedSum = sum.toLocaleString('es-ES', {
             minimumFractionDigits: 0,
             maximumFractionDigits: 0
         });
    
         args.text = CurrencySymbol +
             "<span style='max-width:85px;display:inline-block;overflow:hidden'>" + formattedSum + "</span>";
     }
    

    Markup aspx

       <cc2:C1GridView ID="BagsGrid" runat="server"
           OnDataBound="BagsGrid_DataBound"
           OnClientGroupAggregate="BagsGrid_OnClientGroupAggregate">
           <Columns>
               <cc2:C1TemplateField Visible="False">
                   <GroupInfo HeaderText="Total:" FooterText="Total:" Position="HeaderAndFooter">
                   </GroupInfo>
               </cc2:C1TemplateField>
               <cc2:C1TemplateField>
                   <HeaderTemplate>
                       <asp:CheckBox type="CheckBox" ID="CheckBoxHeader" Checked="true" onclick="javascript:SelectedOrUnSelectedChecked(this);" runat="server" />
                   </HeaderTemplate>
                   <ItemTemplate>
                       <asp:HiddenField ID="HiddenValue" runat="server" Value='<%# Bind("AMOUNT") %>' />
                       <asp:CheckBox ID="CheckBoxGrid" runat="server" Checked="true"
                           CausesValidation="false" AutoPostBack="false" />
                   </ItemTemplate>
                   <ItemStyle Width="40px" />
               </cc2:C1TemplateField>
               <cc2:C1BoundField DataField="AMOUNT" SortExpression="AMOUNT" SortDirection="None"
                   DataFormatString="c0" Aggregate="Custom"
                   HeaderText="Importe">
                   <ItemStyle CssClass="GridNumber" Width="165px" />
               </cc2:C1BoundField>
               <cc2:C1ButtonField ButtonType="Image" CommandName="view_Liquidated"
                   ImageUrl="~/App_Themes/Content/Imagenes/find.png" Text="Liqudiaciones">
                   <ItemStyle Width="50px" />
               </cc2:C1ButtonField>
           </Columns>
       </cc2:C1GridView>

    CheckBox

    //        CheckBox cb = (CheckBox)((C1GridView)sender).Rows[i].Cells[1].FindControl("CheckBoxGrid");
          //        if (cb.Checked)
          //        {
          //            sum += val;
          //        }
                                <cc2:C1TemplateField>
                                    <HeaderTemplate>
                                        <asp:CheckBox type="CheckBox" ID="CheckBoxHeader" Checked="true" onclick="javascript:SelectedOrUnSelectedChecked(this);" runat="server" />
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:HiddenField ID="HiddenValue" runat="server" Value='<%# Bind("AMOUNT") %>' />
                                        <asp:CheckBox ID="CheckBoxGrid" runat="server" Checked="true"
                                            CausesValidation="false" AutoPostBack="false" />
                                    </ItemTemplate>
                                    <ItemStyle Width="40px" />
                                </cc2:C1TemplateField>

    Variable

        string sequence = gridTotalSequence.ToString();
      public partial class SecurityCompanyRetirement : ContentBasePage
      {
          int gridTotalSequence = 1;

    Session, migrate to client ??

               Session["PartialWithdrawGridTotal"] = sum.ToString();
            //    HiddenPartialWithdrawalTotal.Value = sum.ToString();
            //    e.Text = string.Format("{0:C}", sum);

    Please, any suggestions, any help will be very appreciated

  • Posted 9 July 2026, 5:11 am EST

    Hello Enrique,

    • CheckBox: refer to https://developer.mescius.com/forums/webforms-edition/checkbox-c1gridview-2025v2-399#86408

    • Variable: We’re not exactly sure of your use case for using “gridTotalSequence”. Please share more details for us to assist you accordingly.

    • Session: You cannot update ASP.NET Session directly from JavaScript. JavaScript runs in the browser. Session lives on the server. The browser has no access to it. However, you can implement something like the following:

      Keep it in a hidden field.

    <asp:HiddenField
        ID="HiddenPartialWithdrawalTotal"
        runat="server" />

    Whenever the total changes:

    $("#<%=HiddenPartialWithdrawalTotal.ClientID%>").val(sum);

    On the next postback:

    decimal total = decimal.Parse(HiddenPartialWithdrawalTotal.Value);
    Session["PartialWithdrawGridTotal"] = total;

    Please refer to the attached sample we have implemented based on your requirement: GridView_Sample.zip

    Regards,

    Uttkarsh.

  • Posted 14 July 2026, 5:58 am EST - Updated 14 July 2026, 6:19 am EST

    I have several issues about c1gridview. Using gridiview iin ascx, with updatePanel, etc

    I try any simple sample, I get the error about c1gridview

    Error in

    	<asp:UpdatePanel ID="UpdatePanelInPlaceTotalsGrid" runat="server" UpdateMode="Conditional">
    		<ContentTemplate>
    
    			<script type="text/javascript">                            
    
    				function InPlaceTotalsGrid_OnClientGroupAggregate(sender, args) {
    					var CurrencySymbol = '€';
    
    					let sum = 0;
    					let grid = $(sender);
    					let data = grid.c1gridview('dataView');

    Sample, view Testing.aspx

    GridView_RowsSampleTesting.zip

  • Posted 15 July 2026, 12:29 am EST

    Hello Enrique,

    In the sample, we have fixed the following errors:

    • used sender.target to get the grid:
    let grid = $(sender.target);
    let data = grid.c1gridview('dataView');
    • use correct properties to get start and end indexes of the group:
    var startIndex = args.groupingStart;
    var endIndex = args.groupingEnd;
    • parseLocaleNumber() function takes string as parameter but ‘amountText’ being passed is a number. Use parseLocaleNumber() function to get numbers from string only. Corrected code:
    let amountText = row[args.column.dataIndex];
    if (amountText) {
        sum += typeof value === "string" ? parseLocaleNumber(amountText) : amountText;
    }

    Corrected Sample: GridView_RowsSampleTesting.zip

    Regards,

    Uttkarsh.

  • Posted 16 July 2026, 2:49 am EST - Updated 16 July 2026, 4:16 am EST

    Great, it’s working

    function OnClientGroupAggregate(sender, args) {
            let grid = $(sender.target);
            let data = grid.c1gridview('dataView');
    ...
            var startIndex = args.groupingStart;
            var endIndex = args.groupingEnd;
    ...
    
                 let amountText = row[args.column.dataIndex];
                 if (amountText) {
                     sum += typeof value === "string" ? parseLocaleNumber(amountText) : amountText;
                 }
             }

    'es-ES, minimumFractionDigits: 0, maximumFractionDigits: 0 or ‘en-US’ use value 2 ?

             let formattedSum = sum.toLocaleString('es-ES', {
                 minimumFractionDigits: 0,
                 maximumFractionDigits: 0
             });
    
        let formattedSum = sum.toLocaleString('en-US', {
                minimumFractionDigits: 2,
                maximumFractionDigits: 2
            });

    Fails using grid.data

            //if (!grid.data('c1gridview')) {
            //    console.log("Grid no está inicializado aún, retornando...");
            //    return;
            //}
    
  • Posted 16 July 2026, 6:22 am EST

    Hello Enrique,

    → 'es-ES, minimumFractionDigits: 0, maximumFractionDigits: 0 or ‘en-US’ use value 2 ?

    Using 2 fraction digits, the aggregate is displayed as “€105,00”, whereas using 0 fraction digits, it is displayed as “€105”. Please choose the option that best suits your use case.

    → Fails using grid.data

    We’re sorry, but we couldn’t fully understand your requirement. Could you please provide more details about** grid.data**? Specifically, what is grid, and what does the grid.data expression return? It would also be helpful if you could share the complete code snippet where you’re using it.

    Regards,

    Uttkarsh.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels