Completed
Last Updated: 24 Nov 2016 11:32 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 31 Mar 2016 07:29
Category: GridView
Type: Bug Report
0
FIX. RadGridView - summary rows in the child template are not updated when the FormatString property is changed
To reproduce:

private void Form2_Load(object sender, EventArgs e) 
{ 
    this.productsTableAdapter.Fill(this.nwindDataSet.Products); 
    this.categoriesTableAdapter.Fill(this.nwindDataSet.Categories);

    this.radGridView1.AutoGenerateHierarchy = true;
    this.radGridView1.DataSource = this.nwindDataSet;
    this.radGridView1.DataMember = "Categories";
    this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.MasterTemplate.Templates.First().AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

    GridViewSummaryItem summaryItem = new GridViewSummaryItem();
    summaryItem.Name = "CategoryID";
    summaryItem.Aggregate = GridAggregateFunction.Count;
    GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem();
    summaryRowItem.Add(summaryItem);
    this.radGridView1.SummaryRowsTop.Add(summaryRowItem);

    GridViewSummaryItem summaryItem2 = new GridViewSummaryItem();
    summaryItem2.Name = "UnitPrice";
    summaryItem2.Aggregate = GridAggregateFunction.Sum;
    GridViewSummaryRowItem summaryRowItem2 = new GridViewSummaryRowItem();
    summaryRowItem2.Add(summaryItem2);
    this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Add(summaryRowItem2); 
}

private void SetNumberFormat()
{
    this.radGridView1.Columns["CategoryID"].FormatString = "{0:F4}";
    this.radGridView1.SummaryRowsTop[0][0].FormatString = "{0:F4}";

    this.radGridView1.MasterTemplate.Templates.First().Columns["UnitPrice"].FormatString = "{0:F4}";
    this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop[0][0].FormatString = "{0:F4}";
}

private void radButton1_Click(object sender, EventArgs e)
{
    SetNumberFormat();
}

Workaround: Clear and add back the summary rows when a value in the child template is changed. 
private void radButton1_Click(object sender, EventArgs e)
{
    this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Clear();

    GridViewSummaryItem summaryItem2 = new GridViewSummaryItem();
    summaryItem2.Name = "UnitPrice";
    summaryItem2.Aggregate = GridAggregateFunction.Sum;
    GridViewSummaryRowItem summaryRowItem2 = new GridViewSummaryRowItem();
    summaryRowItem2.Add(summaryItem2);
    this.radGridView1.MasterTemplate.Templates.First().SummaryRowsTop.Add(summaryRowItem2); 

    SetNumberFormat();
}
Attached Files:
0 comments