Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
935
How to Change Summary Row Name in Code Behind
posted

Hi this below code display summary in my webdatagrid. I am looking  for ways how can i change the Summary Name Like Sum to Total FG Summary something like that.

Thanks in Regards

 

 SummaryRow fs = WebDataGridPicklistBatch.Behaviors.CreateBehavior<SummaryRow>();

 

            //add default summaries

            if (!this.IsPostBack && fs != null)

            {

                ColumnSummaryInfo info1 = new ColumnSummaryInfo();

                info1.ColumnKey = "FGQuantity";

                info1.Summaries.Add(SummaryType.Sum);

                fs.ColumnSummaries.Add(info1);

 

                ColumnSummaryInfo info2 = new ColumnSummaryInfo();

                info2.ColumnKey = "POQuantity";

                info2.Summaries.Add(SummaryType.Sum);

                fs.ColumnSummaries.Add(info2);

            }

 

Parents
No Data
Reply
  • 8160
    Verified Answer
    posted

    Hi NewbApps,

    you will have to set Custom Summary Name, in your case it should be something like:


     SummaryRow fs = WebDataGridPicklistBatch.Behaviors.CreateBehavior<SummaryRow>();

     

                //add default summaries

                if (!this.IsPostBack && fs != null)

                {

                    ColumnSummaryInfo info1 = new ColumnSummaryInfo();

                    info1.ColumnKey = "FGQuantity";

                    Summary summary = new Summary();
        summary.CustomSummaryName = "Total FG ";
        summary.SummaryType = SummaryType.Sum;

        info1.Summaries.Add(summary);

                    fs.ColumnSummaries.Add(info1);

     

                    ColumnSummaryInfo info2 = new ColumnSummaryInfo();

                    info2.ColumnKey = "POQuantity";

        Summary summary = new Summary();
        summary.CustomSummaryName = "Total FG ";
        summary.SummaryType = SummaryType.Sum;

        info2.Summaries.Add(summary);

                    fs.ColumnSummaries.Add(info2);

                }

    However this will change the summary name only in the summary row. To change it in both places Summary Row and the Summary Selection window you may use something like:

            //Create SummarySetting
            SummarySetting ss = new SummarySetting();
            ss.CustomSummaryName = "Total FG";
            ss.SummaryType = SummaryType.Sum;
    
            //Create SummaryRowSetting
            SummaryRowSetting srs = new SummaryRowSetting(WebDataGridPicklistBatch, "FGQuantity");
    
            //Add SummarySetting to the SummaryRowSetting
            srs.SummarySettings.Add(ss);
    
            SummaryRow fs = WebDataGridPicklistBatch.Behaviors.CreateBehavior<SummaryRow>();
            fs.ColumnSettings.Add(srs);
    
            ColumnSummaryInfo info3 = new ColumnSummaryInfo();
            info3.ColumnKey = "FGQuantity";
            
            Summary summary = new Summary();
            summary.CustomSummaryName = "Total FG";
            summary.SummaryType = SummaryType.Sum;
    
            info3.Summaries.Add(summary);
    
            fs.ColumnSummaries.Add(info3);
    


    For example:

    Please let me know if these suggestions are helpful

Children