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

Items enumerator

1 Answer 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 10 Jan 2012, 09:21 PM
Is there a way to enumerate the items; i.e. textboxes, contained in a section of the report, say the LabelsGroupFooter, or a panel contained in a report section?

Thanks

I think I've stumbled upon a means to do this, probably a better way, but the following works:
IEnumerator itemEnumerator = this.pnlTotals.Items.GetEnumerator();
  
while (itemEnumerator.MoveNext())
{
  if (itemEnumerator.Current.GetType() == typeof(Telerik.Reporting.TextBox))
  {
    Telerik.Reporting.TextBox textBox = (Telerik.Reporting.TextBox)itemEnumerator.Current;
  
    // value contains an expression, vs. literal text?
    if (textBox.Value.StartsWith("="))
      textBox.Value = "0";
  }
}

"pnlTotals" is a panel control which sits in the labelsGroupFooter. It has the textboxes which contain the totals from each column of the report. The purpose of this "excercise" is to flush out column totals if there's no data in the report datasource. This is done in the report NeedDataSource event handler.

  // bind the data table to the .DataSource property of the report
 (sender as Telerik.Reporting.Processing.Report).DataSource = this.dtSource;
 // if the query didn't return any rows, hide the groups and the detail section        
 if (this.dtSource.Rows.Count == 0)
 {
   this.gL_ACCT_CODEGroup.Visible = false;
   this.dEPT_CODE_NAMEGroup.Visible = false;
   this.detail.Visible = false;
   IEnumerator itemEnumerator = this.pnlTotals.Items.GetEnumerator();
   while (itemEnumerator.MoveNext())
   {
     if (itemEnumerator.Current.GetType() == typeof(Telerik.Reporting.TextBox))
     {
       Telerik.Reporting.TextBox textBox = (Telerik.Reporting.TextBox)itemEnumerator.Current;
       // value contains an expression, vs. literal text?
       if (textBox.Value.StartsWith("="))
         textBox.Value = "0";
     }
   }
 }



1 Answer, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 01 May 2012, 11:04 PM
I'm trying to do something similar, but instead of setting the .Value property of textboxes in the group footer, contained in a panel control, I'm attempting to set the values of the textboxes in the detail section. However, when the report is displayed, the zero values are not being display... just an empty detail section.

public static void ZeroColumnTotals(Telerik.Reporting.DetailSection detailSection)
{
  IEnumerator textBoxes = detailSection.Items.Find(typeof(Telerik.Reporting.TextBox)).GetEnumerator();
  while (textBoxes.MoveNext())
  {
    Telerik.Reporting.TextBox textBox = textBoxes.Current as Telerik.Reporting.TextBox;
    if (textBox.Value.StartsWith("=") || textBox.StyleName == "Data")
    {
      textBox.Value = "0";
    }
  }
}

Here's where the ZeroColumnTotals() is being called in the report .NeedDataSource event handler:
(sender as Telerik.Reporting.Processing.Report).DataSource = this.dtSource;

// if the data table is empty...
if (this.dtSource.Rows.Count == 0)
{
  // zero-out the column totals in the detail section  
  ReportUtilities.ZeroColumnTotals(this.detail);
}

Any ideas of what's going on?

Thanks,

--Patrick
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Share this question
or