24 Answers, 1 is accepted
As of R3 2016, in you can access and modify only the processing elements. Any changes applied to the report definition or its items in events will not be applied.
For more detailed information you can refer to the following resources:
Regards,
Katia
Telerik by Progress
Hello Katia,
Thank you for your response. I did not get your answer properly. Can you please elaborate more?
Here is the sample code that I am trying to bind.
public void Report_ItemDataBinding(object sender, EventArgs e)
{
this.textBox2.Value = ReportHelper.GetAccountID(ReportParameters["AccountID"].Value);
}
My final report doesn't show any value in that textbox2. And the same code was working before upgrading to R3 2016.
In your scenario, it might be easier to set the value of the TextBox to an expression that uses a custom function, for = ReportHelper.GetAccountID(Parameters.AccountID.Value).
Otherwise, to set the TetxBox's value inside the event handler you need to use the processing TextBox, for example:
private
void
detail_ItemDataBinding(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.DetailSection section = (sender
as
Telerik.Reporting.Processing.DetailSection);
Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(section,
"textBox1"
);
txt.Value =
"new value"
;
}
Regards,
Katia
Telerik by Progress
Thanks for the response. But my textbox is in pageHeaderSection1, Can I know how to bind the data with it.
I am trying in this way but, it didn't work for me.When I was debugging I get the null data into pageHeader. Can you please let me know what's wrong with my code.
private void pageHeaderSection1_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.PageSection pageHeader = sender as Telerik.Reporting.Processing.PageSection;
Telerik.Reporting.Processing.TextBox txt =(Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(pageHeader, "textBox2");
txt.Value=Convert.ToDateTime(ReportParameters["FromDate"].Value);
}
The code you provided works as expected on our side, see the attached report.
Note, that the above scenario can be achieved without the usage of events. Instead, you can set the value of the textBox to the expression. Expressions can contain parameter values, built-in functions and custom functions.
Regards,
Katia
Telerik by Progress
I got it. And it is working fine for me now. Thank you so much.
In our last version, we were binding all textbox values from pageHeader,pageFooter and Report backgrounds from single ItemDataBinding event. Which works fine at that time.
Now we have to seperate ItemDatabinding events to pageHeader,pageFooter etc..
Can I know the reason why it is not working in Latest Version? Did you change any architecture?
Please check the below sample code from my previous version.
In the below Sample code textbox18 is from pageHeader and textbox26 is from pageFooter and also we are changing the report header logo. Also attaching sample designer in text file to show where I was calling this BindingEvent.
Report.cs
private void Report_ItemDataBinding(object sender, EventArgs e)
{
textBox18.Value = textBox26.Value =
Convert.ToDateTime(ReportParameters["FromDate"].Value);
if (logo() == "abc")
{
this.reportHeader.Style.BackgroundImage.ImageData =
Images.abc_logo;
}
else
{
this.reportHeader.Style.BackgroundImage.ImageData =Images.logo2;
}
}
Report.designer.cs
?
//
// pageFooter
//
this.pageFooter.Height = Telerik.Reporting.Drawing.Unit.Inch(0.42916667461395264D);
this.pageFooter.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.textBox17,
this.textBox18,
this.textBox19,
this.tbFooterReportId});
this.pageFooter.Name = "pageFooter";
//
// pageHeaderSection1
//
this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(1.3000000715255737D);
this.pageHeaderSection1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.titleTextBox,
this.textBox26});
this.pageHeaderSection1.Name = "pageHeaderSection1";
//
// Report1
//
group1.GroupFooter = this.groupFooterSection;
group1.GroupHeader = this.groupHeaderSection;
group1.Name = "group";
this.Groups.AddRange(new Telerik.Reporting.Group[] {
group1});
this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.groupHeaderSection,
this.groupFooterSection,
this.pageHeaderSection1,
this.detail,
this.pageFooterSection1});
this.Name = "Report1";
this.PageSettings.Margins = new Telerik.Reporting.Drawing.MarginsU(Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D), Telerik.Reporting.Drawing.Unit.Inch(1D));
this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
reportParameter1.Name = "FromDate";
reportParameter1.Type = Telerik.Reporting.ReportParameterType.DateTime;
reportParameter1.Value = "= Today()";
reportParameter1.Visible = true;
this.ReportParameters.Add(reportParameter1);
styleRule1.Selectors.AddRange(new Telerik.Reporting.Drawing.ISelector[] {
new Telerik.Reporting.Drawing.StyleSelector("Heading1")});
styleRule1.Style.Font.Bold = true;
styleRule1.Style.Font.Italic = true;
styleRule1.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(20D);
this.StyleSheet.AddRange(new Telerik.Reporting.Drawing.StyleRule[] {
styleRule1});
this.Width = Telerik.Reporting.Drawing.Unit.Inch(6D);
this.ItemDataBinding += new System.EventHandler(this.Report_ItemDataBinding);
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
In versions prior to R3 2016, all changes in events were accepted, even these applied on items' definitions. This was changed in R3 2016 due to the optimizations in the processing and how item definitions' properties are read and stored.
For more details check:
Regards,
Katia
Telerik by Progress
Katia,
I am applying the above mentioned ItemDatabinding to several reports. Some of the reports works fine but some doesn't show data in pageHeaderSection. Am I missing anything?
And for some reports I am giving data manually for example textbox1.value= Titleabc and I am binding it to the PageHeaderSection which doesn't display any data. Please let me know if I am doing anything wrong.
Katia,
I am applying similar ItemDataBinding to several reports according to the code you posted. but some of them work fine and some of them are not showing any data in pageHeaderSection1.
And for some reports , I am giving the pageHeader title in the textbox value manually. for Example, textbox1.value = Titleabc. It doesn't show the title in the pageHeaderSection when I run my report. Am I missing anything? Please let me know.
I am not certain about the exact scenario, the structure of the report and the full customizations you apply to the report.
If you are working with item definition (textbox1.value = ) inside the event handler the changes will not be applied - Changes on items in report events are not applied. Thus, you need to check if you are working with processing item.
Regards,
Katia
Telerik by Progress
Hi,
I have a PageHeaderSection and GroupHeaderSection.
I need to display PageHeaderSection when no records present and display GroupheaderSection when there are records.
It works fine. but, I get the whitespace for the PageHeaderSection when I want to display records which doesn't look good. Is there any solution to hide the whitespace? Please let me know.
Thanks
This behavior is expected for the page sections. The space taken up by PageHeader or PageFooter sections would always be reserved no matter whether they are visible or not - Understanding Rendering Behaviors(Page Header and Footer sections).
In upcoming R1 2017 release, we plan to change this behavior and to add the ability for the page sections to be collapsed when hidden - Roadmap for R1 2017.
Regards,
Katia
Telerik by Progress
Thanks for the response.
I have below scenario.
//
// reportHeader
//
this.reportHeader.Height = Telerik.Reporting.Drawing.Unit.Inch(1.25D);
this.reportHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.titleTextBox,
this.textBox26});
this.reportHeader.Name = "reportHeader";
this.reportHeader.Style.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(144)))), ((int)(((byte)(171)))), ((int)(((byte)(199)))));
this.reportHeader.Style.BackgroundImage.MimeType = "image/png";
this.reportHeader.Style.BackgroundImage.Repeat = Telerik.Reporting.Drawing.BackgroundRepeat.NoRepeat;
this.reportHeader.ItemDataBinding += new System.EventHandler(this.reportHeader_ItemDataBinding);
//
// textBox26
//
this.textBox26.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.02083333395421505D), Telerik.Reporting.Drawing.Unit.Inch(0.77920609712600708D));
this.textBox26.Name = "textBox26";
this.textBox26.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(8.5624618530273438D), Telerik.Reporting.Drawing.Unit.Inch(0.47071495652198792D));
this.textBox26.Style.Font.Name = "Arial";
this.textBox26.Style.Font.Size = Telerik.Reporting.Drawing.Unit.Point(10D);
this.textBox26.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
this.textBox26.StyleName = "RHeader_ParmText";
this.textBox26.Value = "";
This is my code
private void reportHeader_ItemDataBinding(object sender, EventArgs e)
{
// Set account name in page header/footer
Telerik.Reporting.Processing.ReportSection reportHeader = sender as Telerik.Reporting.Processing.ReportSection;
Telerik.Reporting.Processing.TextBox txt26 = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(reportHeader, "textBox26");
txt26.Value =
ReportHelper.GetAccountNames(ReportParameters["AccountID"].Value);
}
I am not able to see Textbox26 value on my report header when I run my final report. I couldn't figure out what's wrong with this.
Please let me know.
Thanks
Inside the event handlers, you can work only with processing items. This applies to report parameters as well. An example of how to get the processing report parameter is provided here.
To reach the outer container you can use ProcessingElement.ParentElement property.
Regards,
Katia
Telerik by Progress
I am still facing the same issue. When I debug this I wam able to see the data for txt26.value. But, it is not displaying in my final result.
Can you please provide any example ?
private void reportHeader_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.ReportSection reportHeader = sender as Telerik.Reporting.Processing.ReportSection;
Telerik.Reporting.Processing.TextBox txt26 = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(reportHeader, "textBox26");
txt26.Value =ReportHelper.GetAccountNames(reportHeader.Report.Parameters["AccountID"].Label);
}
My report doesn't even display if I write my txt26.value as "abc". Please see the below code. I am not sure what's wrong with my code.
private void reportHeader_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.ReportSection reportHeader = sender as Telerik.Reporting.Processing.ReportSection;
Telerik.Reporting.Processing.TextBox txt26 = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(reportHeader , "textBox26");
txt26.Value = "abc";
}
Hi,
I had the same error and making changed to web.config works fine on my local machine but when the same changes are applied on server in web.config it throws error "Object Reference not set to an instance of an object"
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- section handler ok; 1 extension -->
<configSections>
<section
name="Telerik.Reporting"
type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting.Configuration, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<Telerik.Reporting>
<processing cacheDefinitionProperties="false" />
</Telerik.Reporting>
</configuration>
The object Reference error is thrown at Telerik.Reporting.Processing.AbsolutePositionLayout.MeasureHorizontalContent.
Kindly help
Hello Pragati,
In R1 2020 SP1 we fixed an issue that causes an exception to be thrown when the cached of the definition properties is turned off. You can check the release notes here and our suggestion is to download the latest service pack or internal build and see if the issue still persists on your side.
Regards,
Ivan Hristov
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
After upgrading to version 14 I faced issues with updating values of controls/elements (textboxes/grids) on the report in events like NeedDataSource and ItemDataBinding.
I came across a fix by adding a configuration so that it is applied to multiple reports at the same time. The configuration is as below.
<configSections>
<section
name="Telerik.Reporting"
type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=14.0.20.219, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
allowLocation="true"
allowDefinition="Everywhere" />
</configSections>
<Telerik.Reporting>
<processing cacheDefinitionProperties="false" />
</Telerik.Reporting>
After applying this configuration some reports work fine while some of them still do not display the data which is manipulated under the report events.
Also the reports started throwing errors when the data in Telerik.Reporting.Texbox was larger in length than specified on the report. Even though multiline, wrapping on the textbox was set to true. I had to manually increase the size of these textboxes to make it work.
Is there a configuration that can fix both issues?
Hi Pragati,
The report events are not intended to be used as a place/time to modify the report definition, as explained in the Understanding Events article. In R3 2016 for performance reasons we introduced a change which caches the report definition properties so such modifications are not respected. As you've discovered, this change can be disabled through the configuration with the cacheDefinitionProperties flag. I suggest to check this KB article if you haven't already done so: Changes on items in report events are not applied.
However, setting the cacheDefinitionProperties to false should produce the same results as with the older versions of Telerik Reporting. Also the textboxes should not throw an error when their contents do not fit in the textbox bounds. We want to investigate further, so I would like to ask you to send us a sample project that reproduces the issue so we can examine it on our side.
Thank you in advance.
Regards,
Ivan Hristov
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
I have added a sample project files (web page, report, web.config) which gives me the error in discussion. Telerik.Reporting version used is 14.0.20.219
The cacheDefinitionProperties is turned off. When I render the report it gives me the error.
https://github.com/gupta27ankit/TelerikReportTest-v2020SP1
Regards,
Pragati
Hi Pragati,
Using the files supplied with the project the PDF report can be generated correctly on my side. The value of the TextBox located in the Page Header section is populated correctly and I do not encounter the "Object Reference not set to an instance of an object" error.
I suggest putting a breakpoint into the Page_Load method and run the application in a debug mode, this might give additional information about the exception and where exactly it occurs.
Regards,
Katia
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.