I have played around with the Telerik.Reporting class, but because of poor knowledge within OO I find it a bit tricky. Could someone explain to me how I can find the csvDataSource I have added to my csvtest.trdx report? I have made a report in the designer, added a csvDataSource1 that has csvDataSource1:Source = "file:///C:/Users/Temp/slettme.csv".
In my class, I have: and it works swell to view the report. Now I want to be able to change the path for my report to something else than what I have added in the report. How do I find the csvdatasource in play?
THIS-OBJECT:reportViewer1 = NEW Telerik.ReportViewer.WinForms.ReportViewer(). THIS-OBJECT:SuspendLayout(). /* */ /* reportViewer1 */ /* */ THIS-OBJECT:reportViewer1:Dock = System.Windows.Forms.DockStyle:Fill. THIS-OBJECT:reportViewer1:Location = NEW System.Drawing.Point(0, 0). THIS-OBJECT:reportViewer1:Name = "reportViewer1". THIS-OBJECT:reportViewer1:Size = NEW System.Drawing.Size(421, 400). THIS-OBJECT:reportViewer1:TabIndex = 0. THIS-OBJECT:reportViewer1:Load:Subscribe(THIS-OBJECT:reportViewer1_Load_1). /* */ /* slettme */ /* */ THIS-OBJECT:ClientSize = NEW System.Drawing.Size(421, 400). THIS-OBJECT:Controls:Add(THIS-OBJECT:reportViewer1). THIS-OBJECT:Name = "slettme". THIS-OBJECT:Text = "slettme". METHOD PRIVATE VOID reportViewer1_Load_1( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):: RDS = new Telerik.Reporting.UriReportSource(). RDS:Uri = search("reports/csvtest.trdx"). this-object:reportViewer1:ReportSource = RDS. THIS-OBJECT:reportViewer1:refreshreport(). return. END.
Interesting post. I am going to make sure someone from the Telerik Reporting team takes a look at this.... I don't think they are currently actively monitoring this forum, even though some of them have been playing with OpenEdge.
While I am doing that, I would be interested in what problem you are trying to solve using the Telerik Reporting .NET viewer in OpenEdge GUI4.NET. Deploying the Reporting Viewer in ABL .NET Forms is a use case that seems very appealing and you have noted one key point -- that you want to set the ReportSource programatically from the ABL (rather than using the reportSource attribute). So good job there!
But would you mind sharing the use case, and what you are thinking about, and what you want to report on?
Thanks in advance.
I have made my first CSV report in Telerik, and finds it very appealing to work with. It was easy to make groups and work with numbers etc. Now I have made a class that gives me a reportviewer in a ABL form. Very cool to implement into my progress world. As a start, I would like to produce a file with the correct layout, and fill it with my report data. For that reason I need to chance the file-name that was used in the Report Designer. Of course I can edit the .trdx file and change the filename in there, but it should be possible to do it in another way :-)
my .trdx file.......
<Report DataSourceName="csvDataSource1" Width="6.5in" Name="slettmeg" SnapGridSize="0.1cm" xmlns="schemas.telerik.com/.../3.7">
<DataSources>
<CsvDataSource RecordSeparators="
" FieldSeparators="," Name="csvDataSource1">
<Source>
<Uri Path="file:///C:/Users/Temp/slettme2.csv" />
</Source>
<Columns>
<DataColumn Name="Column1" Type="Integer" />
<DataColumn Name="Column2" />
<DataColumn Name="Column3" />
<DataColumn Name="Column4" Type="Decimal" />
:
:
>> I need to change the file-name that was used in the Report Designer. Of course I can edit the .trdx file and change the filename in there, but it should be possible to do [this programmatically]
(I was able to get a quick turnaround on the answer -- I am repeating it 'verbatim', and it is not ABL-ready code -- so I hope you can translate.....)
Hi goo,
You have a report definition that is in trdx format. Your requirement is to change the definition at runtime a little bit in some way. In order to do that you need to
Sample 1
See the code below as an example how to deserialize the report trdx definition (note that all code samples are written in CSharp) (source: http://www.telerik.com/help/reporting/programmatic-xml-serialization.html):
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings(); settings.IgnoreWhitespace = true; using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create
("Report1.xml", settings)) { Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer(); Telerik.Reporting.Report report = (Telerik.Reporting.Report) xmlSerializer.Deserialize(xmlReader); }
Sample 2
Now that you have the report instance use the reporting API to modify the data source (http://www.telerik.com/help/reporting/p_telerik_reporting_csvdatasource_source.html):
var csvDataSource = (CsvDataSource)report.DataSource; csvDataSource.Source = new Uri(“C:\Users\Temp\slettme.csv”)
Sample 3
Then pass the modified report instance to the report viewer control and refresh the rendered report:
Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); // Assigning the Report object to the InstanceReportSource instanceReportSource.ReportDocument = report; this.reportViewer1.ReportSource = instanceReportSource; this.reportViewer1.Refreshreport();
Hope that helps.
There is another approach which will require much easier modification of the csv path – in the definition to change the path to the csv to be an expression like
= Parameters.CsvPath
And add such report parameter to the report definition. Then in the viewer setup code you may use UriReportSource with parameter value.
See http://www.telerik.com/help/reporting/report-sources-viewers.html
var csvDataSource = (CsvDataSource)report.DataSource;
csvDataSource.Source = new Uri(“C:\Users\Temp\slettme.csv”)
I changed the .trdx file by using XML parser hDoc:load("FILE".....)...... but after hDoc:Save("FILE"....) it changed this line:
<DataSources>
<CsvDataSource RecordSeparators="
" FieldSeparators="," Name="csvDataSource1">
:
:
to this:
<DataSources>
<CsvDataSource FieldSeparators="," Name="csvDataSource1" RecordSeparators="
">
AS you can see, some characters has been removed from RecordSeparators... how can I get around that?
The tricky translation here is the CAST from Telerik.Reporting.Report.DataSource to Telerik.Reporting.Report.CvsDataSource.
Telerik.Reporting.Report report = (Telerik.Reporting.Report)
xmlSerializer.Deserialize(xmlReader); var csvDataSource = (CsvDataSource)report.DataSource;
This is done with a CAST () in ABL. (see http://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/cast-function.html)
If you are looking for a quick way to get started without learning OOABL, then you might want to consider this.
This is not the most technically elegant solution, but it occurs to me you could have the .trdx file point to "report.cvs", and you could use ABL to overwrite the report.cvs every time (or copy from an existing file) rather than trying to manipulate it.
Hi goo,
No need to parse the report definition XML manually. Instead deserialize the report instance (Sample 1), modify the in-memory report definition instance (Sample 2) and pass this instance to the viewer (Sample 3). Once you have a live instance of the report, you use InstanceReportSource to feed the viewer instead of the UriReportSource.
In Sample 2 you need to CAST the reports' data source to CsvDataSource as the DataSource property of the report is of type Telerik.Reporting.DataSource so that different data sources may be used. However you know that in yuor particular report the data source is actually CsvDataSource and you need to change one particular property of that CsvDataSurce.
So the line
var csvDataSource = (CsvDataSource)report.DataSource;
should be translated into ABL to
DEFINE PUBLIC VARIABLE csvDataSource AS Telerik.Reporting.CsvDataSource NO-UNDO.
csvDataSource = CAST(report:DataSource, CsvDataSource)
Hope this helps.
Milen
The tricky translation here is the CAST from Telerik.Reporting.Report.DataSource to Telerik.Reporting.Report.CvsDataSource.
Telerik.Reporting.Report report = (Telerik.Reporting.Report) xmlSerializer.Deserialize(xmlReader);
var csvDataSource = (CsvDataSource)report.DataSource;
This is done with a CAST () in ABL. (see http://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/cast-function.html)
If you are looking for a quick way to get started without learning OOABL, then you might want to consider this.
This is not the most technically elegant solution, but it occurs to me you could have the .trdx file point to "report.cvs", and you could use ABL to overwrite the report.cvs every time (or copy from an existing file) rather than trying to manipulate it.
Flag this post as spam/abuse.
Hi goo,
No need to parse the report definition XML manually. Instead deserialize the report instance (Sample 1), modify the in-memory report definition instance (Sample 2) and pass this instance to the viewer (Sample 3). Once you have a live instance of the report, you use InstanceReportSource to feed the viewer instead of the UriReportSource.
In Sample 2 you need to CAST the reports' data source to CsvDataSource as the DataSource property of the report is of type Telerik.Reporting.DataSource so that different data sources may be used. However you know that in yuor particular report the data source is actually CsvDataSource and you need to change one particular property of that CsvDataSurce.
So the line
var csvDataSource = (CsvDataSource)report.DataSource;
should be translated into ABL to
DEFINE PUBLIC VARIABLE csvDataSource AS Telerik.Reporting.CsvDataSource NO-UNDO.
csvDataSource = CAST(report:DataSource, CsvDataSource)
Hope this helps.
Milen
Flag this post as spam/abuse.
DEFINE PUBLIC VARIABLE myReport AS Telerik.Reporting.Report NO-UNDO.
DEFINE PUBLIC VARIABLE csvDataSource AS Telerik.Reporting.CsvDataSource NO-UNDO.
myReport = new Telerik.Reporting.Report().
csvDataSource = new Telerik.Reporting.csvDataSource().
csvDataSource = CAST(myReport:DataSource, CsvDataSource).
This will not compile…. So I probably should use the kind of strange solution that I got to work.
Anyway, thanks for trying to make me understand J
//Geir Otto
Can you share the error message? I am wondering if you have the correct "USING" statement. The code above where you CAST (myReportDataSource, CsvDataSource) only works if the namespace for CsvDataSource can be resolved.
The full class name is "Telerik.Reporting.CsvDataSource"
There is a section in the OpenEdge online documentation in this: C# .NET code mapped to OpenEdge GUI for .NET ABL
You want to look at the section on Casting. Approximately, your code should look like.
USING Telerik.Reporting.*. DEFINE PUBLIC VAR myReport AS Report NO-UNDO. DEFINE PUBLIC VAR csvDataSource AS CsvDataSource NO-UNDO. myReport = new Report(). csvDataSource = CsvDataSource(). csvDataSource = CAST(myReport:DataSource, CsvDataSource).
(Note: in your cut/pasted code, you also had referred to the CvsDataSource CLASS as 'Telerik.Reporting.cvsDataSource" with different capitalization. For .NET components, the case is important. [Clarification -- I was told after the post that ABL does not require matching capitalization for .NET classes -- .NET Classes are treated as case-insensitive EXCEPT for the first reference. The first reference does need to identify the class and package by name 'correctly' with the same Case as the .NET definition.]:
If you could share the error, it might point to which one of the above problems you were running into.)
FYI... on the last post I had incorrectly talked about case-sensitivity. For .NET Classes, the ABL is case-insensitive. You don't need to match the case when you reference classes.
(Also, I noted a few typos in my code sample which I corrected.)
FYI... on the last post I had incorrectly talked about case-sensitivity. For .NET Classes, the ABL is case-insensitive. You don't need to match the case when you reference classes.
(Also, I noted a few typos in my code sample which I corrected.)
Flag this post as spam/abuse.
Can you share the error message? I am wondering if you have the correct "USING" statement. The code above where you CAST (myReportDataSource, CsvDataSource) only works if the namespace for CsvDataSource can be resolved.
The full class name is "Telerik.Reporting.CsvDataSource"
There is a section in the OpenEdge online documentation in this: C# .NET code mapped to OpenEdge GUI for .NET ABL
You want to look at the section on Casting. Approximately, your code should look like.
USING Telerik.Reporting.
DEFINE PUBLIC VAR myReport Report NO-UNDO.
DEFINE PUBLIC VAR csvDataSource AS CsvDataSource NO-UNDO.
myReport = new Report().
csvDataSource = CsvDataSource().
csvDataSource = CAST(myReport:DataSource, CsvDataSource).
(Note: in your cut/pasted code, you also had referred to the CvsDataSource CLASS as 'Telerik.Reporting.cvsDataSource" with different capitalization. For .NET components, the case is important. If you could share the error, it might point to which one of
the above problems you were running into.)
Flag this post as spam/abuse.
Flag this post as spam/abuse.
Thanks for the error message.
The issue is that you are trying to use CAST (object, class) with two objects. The second paramter is not the 'instance', but the class reference. Thjis is definitely not 'obvious' if you are not used to OOABL programming and .NET.
You had:
myDataSource = CAST(report:DataSource, myDataSource).
You want:
myDataSource = CAST(report:DataSource, Telerik.Reporting.CvsDataSource).
The code sample in the forum post earlier shows a more complete sample (Look at in in a browser, The content was edited after the post so the email content is out of date)
Hi,
I am catching up with the ABL syntax, so here is a runnable tested ABL version of the originally provided code (Sample 1, 2, 3)
Note that you need to replace the actual paths to your report definition and runtime csv data.
/* Deserialize the report instance from the report definition trdx */ DEFINE VARIABLE xmlSettings AS System.Xml.XmlReaderSettings. xmlSettings = NEW System.Xml.XmlReaderSettings(). xmlSettings:IgnoreWhitespace = TRUE. DEFINE VARIABLE xmlReader AS System.Xml.XmlReader. xmlReader = System.Xml.XmlReader:Create("C:\Work\Research\trdx\CsvReport.trdx", xmlSettings). DEFINE VARIABLE xmlSerializer AS Telerik.Reporting.XmlSerialization.ReportXmlSerializer. xmlSerializer = NEW Telerik.Reporting.XmlSerialization.ReportXmlSerializer(). DEFINE VARIABLE reportInstance AS Telerik.Reporting.Report. reportInstance = CAST(xmlSerializer:Deserialize(xmlReader), Telerik.Reporting.Report). xmlReader:Dispose(). /* Modify the report instance as needed */ DEFINE VARIABLE csvDataSource AS Telerik.Reporting.CsvDataSource. csvDataSource = CAST(reportInstance:DataSource, Telerik.Reporting.CsvDataSource). csvDataSource:Source = NEW System.Uri("C:\Work\Research\trdx\ds.txt"). /* Use the modified in-memory report definition in my app */ DEFINE VARIABLE instanceReportSource AS Telerik.Reporting.InstanceReportSource. instanceReportSource = NEW Telerik.Reporting.InstanceReportSource(). instanceReportSource:ReportDocument = reportInstance. THIS-OBJECT:reportViewer1:ReportSource = instanceReportSource. THIS-OBJECT:reportViewer1:RefreshReport().
Hope this helps.
Milen