datamembers in reports

Stimulsoft Reports.NET discussion
Post Reply
zreptil
Posts: 18
Joined: Tue Aug 19, 2008 1:17 am

datamembers in reports

Post by zreptil »

hi there,

i tried reports.net and find it very useful. i assigned data to the reports and everything works fine as long as the data contains getters for every property i need on the report. is it possible to have the properties of the data assigned to a report that don't have a getter?

for example:

class FormData
{
public String Name;
public double Price;
}

FormData myData;

when i assign this data with

report = new StiReport();
report.RegData("MyFormData", myData)

then i dont see any members. I need this data to be a class, a struct won't work with the rest of the program. Is it possible to get this working? Or have there to be getters for the properties?

thanks in advance
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

datamembers in reports

Post by Edward »

Hello.

Yes, it is possible to register such a class in the report's Dictionary. Here is some options which control this behavior:

Stimulsoft.Report.StiOptions.Dictionary.BusinessObjects.AllowUseFields
Stimulsoft.Report.StiOptions.Dictionary.BusinessObjects.AllowUseProperties

StiFieldsProcessingType Stimulsoft.Report.StiOptions.Dictionary.BusinessObjects.FieldsProcessingType

public enum StiFieldsProcessingType
{
All,
Browsable
}

StiPropertiesProcessingType Stimulsoft.Report.StiOptions.Dictionary.BusinessObjects.PropertiesProcessingType

public enum StiPropertiesProcessingType
{
All,
Browsable
}

//Maximum level of nesting of master-detail relations in enumerable sources.
public static int Stimulsoft.Report.StiOptions.Dictionary.BusinessObjects.MaxLevel

These properties are static and you have to set them in a very beginning of your application.

Thank you.
zreptil
Posts: 18
Joined: Tue Aug 19, 2008 1:17 am

datamembers in reports

Post by zreptil »

thank you very much, edward. that works for my data :)

i simply put

StiOptions.Dictionary.BusinessObjects.AllowUseFields = true;

in my printclass and it works as it should.

But since it works i have another problem:

whenever i try to preview a report using my data i get an error that says

error cs0246 type or namespace not found

maybe the text differs since i translated it from the german version.

the namespace that is missing is the namespace of my data. where do i assign this namespace within the report? all accessing classes have this namespace in the usings.

thanks in advance for another advice :)
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

datamembers in reports

Post by Edward »

Hello,

Please assign that namespace in the report Designer in the Code Tab in 'using' clause.

Also in the Report.ReferencedAssemblies you have to add the name of the dll or executable file which contains that 'FormData' business object.

Thank you.
zreptil
Posts: 18
Joined: Tue Aug 19, 2008 1:17 am

datamembers in reports

Post by zreptil »

Hi Edward,

it works partially. But how can i assign Data form another DLL? I have a class that is defined in another DLL. For example the report is handled from print.dll and the classes i need to place on a report is located in data.dll.

Now i use the following code to create a new report in the print.dll:

StiReport report = new StiReport();
report.ReferencedAssemblies = new String[] {
"System.Dll",
"System.Drawing.Dll",
"System.Windows.Forms.Dll",
"System.Data.Dll",
"System.Xml.Dll",
"Stimulsoft.Controls.Dll",
"Stimulsoft.Base.Dll",
"Stimulsoft.Report.Dll",
"data.dll"};

report.DataSources.Clear();
report.Script = "using data;\n"
+ report.Script;

report.RegData("BusinessData", data);
report.Design();

"data" is an instance of my data based on a class defined in data.dll. When i execute this, i get the report designer and i have my data in the dictionary under datasources as "BusinessData" with all properties.

But i am not able to place a propertyfield on the report. When i define the datatype in the print.dll and not in the data.dll everything works fine.

Where is my mistake?
zreptil
Posts: 18
Joined: Tue Aug 19, 2008 1:17 am

datamembers in reports

Post by zreptil »

Hi again,

now i know my mistake: the data was simply null. an with null as data i don't wonder anymore that there is no data available.
Post Reply