One To Many Relation and BusinessObjects

Stimulsoft Reports.WPF discussion
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi,

I know this is possible, but I don't know how... ;-)

My reports are base on BusinessObjects that I register to the report. I have now the need for a report that shows a One-to-many relation like this

Code: Select all

 --- Text with Data from the Main-Object (the "one"-object)

      ---- First Item of List of children (the "many" objects)
      ---- Second Item of List of children 
      .
      .
      .
      ---- Last Item of List of children 

 --- Some more Text with Data from the Main-Object 
My question are:
- How do I register the structure of the children BusinessObject class within the dictionary in order to be able to place its properties on the report at desintime? I read that I have to add it as "child" but can't figure out how...
- In what form can I supply the data of the children objects at runtime. Should the main-object just have a List <ChildrenClass> as a property?
- In what kind of band do I have to place the components for the Children to achieve a report like this?

I hope you understand what I mean... :?

Thanks you very much in advance!

Cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: One To Many Relation and BusinessObjects

Post by HighAley »

Hello, Pascal.
PJoyeux wrote:- How do I register the structure of the children BusinessObject class within the dictionary in order to be able to place its properties on the report at desintime? I read that I have to add it as "child" but can't figure out how...
You should just register the parent business object:

Code: Select all

stireport.RegBusinessObject("DataSet", set);
stireport.Dictionary.SynchronizeBusinessObjects(3);
The parameter of the SynchronizeBusinessObjects() method could be used to set depth of the child business objects.
PJoyeux wrote:- In what form can I supply the data of the children objects at runtime. Should the main-object just have a List <ChildrenClass> as a property?
Yes, you are right. You could see the sample nested business object on the MSDN.
PJoyeux wrote:- In what kind of band do I have to place the components for the Children to achieve a report like this?
If you use RegBusinessObject() method to register your business objects, you could just use 2 data bands. If we get the business object from the previous link, you should put one Data Band with Merchant business object and second data band with Product. You don't need to change any other properties. The Master-detailed report will be created automatically.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi Aleksey,

thanks you for your answer!

I have tried and added a List<ChildClass> to my business object and created a band using the list as datasource but no property of the ChildClass is available... I have used the following code:

Code: Select all

aReport.Dictionary.SynchronizeBusinessObjects(3);
But still there is nothing under "BuchungGebuchteExtras":
Bild 3.png
Bild 3.png (11.31 KiB) Viewed 6551 times
What is missing???

Cheers,
Pascal
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi Aleksey,

I was able to create the second databand, but had to manually enter then name of the properties (MainObject.ChildObject.PropertyName) instead of using the BusinessObject-Tree since I still can't access the properties there. My report now prints correctly the data of the MainObject and a List of its ChildObjects.

But...

In your answer you told me to use 2 DataBands. But I need this second band (the one showing the children) to be encased in the main Databand:

Code: Select all

<Main DataBand>
  <Some Text of Main DataBand>    <-- This Works already
  <Children DataBand>                    <-- This Works already
    <Some Data of 1. Child/>
    <Some Data of 2. Child/>
    <Some Data of 3. Child/>
    <Some Data of 4. Child/>
  </Children DataBand>
  <Some more Text of Main DataBand>     <-- How can I do this?
</Main DataBand>
How would I do this? I tried using 3 Bands like this:
Bild 7.png
Bild 7.png (48.17 KiB) Viewed 6548 times
But the result was not what I was looking for...

Do I need a SubbReport, Child bands, ...? Help! ;-)

Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: One To Many Relation and BusinessObjects

Post by HighAley »

Hello.

You could try to put a Container on the Master Data Band and put in this Container Detailed Data Band. Then it will be possible to put Text components after detailed section on the Master Data Band.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi,

I am sorry, but I couldn't figure out what you mean with "container". :?

Could you be so kind as to create a small sample-report with two BusinessObjects "Manufactor" (Main) and "Products" (Children) in such order:

Code: Select all

<Main DataBand (DataSource = Manufactor)>
  <Name of Manufactor>
  <Children DataBand (DataSource Manufactor.Products)>
    <Name of 1. Product of manufactor/>
    <Name of 2. Product of manufactor/>
    ...
    <Name of last Product of manufactor/>
  </Children DataBand>
  <Country of Manufactor>
</Main DataBand>
Of course you can change the sample, it's just for explanation... ;)

Cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: One To Many Relation and BusinessObjects

Post by HighAley »

Hello.

We have made some changes in our Demo report Business Objects - Master-Detail.
WPFMaster-DetailBusinessObjects.mrt
(25.2 KiB) Downloaded 653 times
Under Container I meant Panel component. Sorry, didn't wrote it before.

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi Aleksey,

THANK YOU! Using a Panel I was able to achieve what I needed. 8-)

I could have known that a Panel is a container... I was obviously to tired yesterday... :lol:

I have still the question regarding the availability of the properties of my child-class (http://forum.stimulsoft.com/viewtopic.p ... 879#p71853). Is that fixed in today's patch?

I'd like to thank all of you guys for your dilligent support!

Cheers,
Pascal
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: One To Many Relation and BusinessObjects

Post by HighAley »

Hello.

In our previous versions there was a StiContainer component it was replaced with StiPanel.
The issue with child-class wasn't solved. Could you send us a sample project with your business object for analysis?

Thank you.
User avatar
PJoyeux
Posts: 160
Joined: Tue Nov 26, 2013 9:40 am
Location: Germany

Re: One To Many Relation and BusinessObjects

Post by PJoyeux »

Hi Aleksey,

here's my businessobject and its child-class. But I can't think of anything therein that would cause this problem... All properties are public.

By the way, I can directly access the data from the child-classes using something like this:

Code: Select all

BuchungPrintingBusinessClass.GebuchteExtrasPrintingBusinessClass.Text
I just can't do it via the BusinessObjects Tree...

Cheers,
Pascal
Attachments
BuchungPrintingBusinessClass.cs
(9.36 KiB) Downloaded 414 times
Post Reply