Skip to Content
author's profile photo Former Member
Former Member

Nested multiLevelObjects and GroupReports

Hello

i want to display an nested dot net object with crystal report. the problem that i have is now that one the first line are printed for the second object.

public class Head
{
    public string Name { get; set; }
    [CrystalComplexTypeExpansionLevels(3)]
    public List<Article> Articles { get; set; }
}

public class Article
{
    public int Number { get; set; }
    public string ArticleName { get; set; }
    [CrystalComplexTypeExpansionLevels(3)]
    public List<ArticleText> Text { get; set; }
}

public class ArticleText
{
    public int TextNumber { get; set; }
    public string Text { get; set; }
}

I fill up the object with some data and the expected output should looks like:

Mr.Mayer [Head.Name]
1 [Article.Number] ArticleText1 [Article.ArticleName]
 1 [ArticleText.Textnumber] Text1  [ArticleText.Text] 
 2 [ArticleText.Textnumber] Text2 [ArticleText.Text]
2 [Article.Number] ArticleText1 [Article.ArticleName]
 3 [ArticleText.Textnumber] Text3  [ArticleText.Text] 
 4 [ArticleText.Textnumber] Text4 [ArticleText.Text]

but the output looks like

1 [Article.Number] ArticleText1 [Article.ArticleName]
 1 [ArticleText.Textnumber] Text1  [ArticleText.Text] 
2 [Article.Number] ArticleText1 [Article.ArticleName]
 3 [ArticleText.Textnumber] Text3  [ArticleText.Text]

In the FieldExplorer i can see the hieracical order... for the Object Head. So i can also drilldown the yellow Article and also the Yellow Text Field.

First i create a Group with ArticleName and add the Head.Name to the Page Header, The Number and ArticleName to the GroupHeaderSection1 and TextNumber and Text to DetailSection.

At least i add this code in the form_load

Head h = new Head();
h.Name = "Mr.Mayer";
h.Articles = new List<Article>();
int r = 1;
for (int i = 1; i < 3; i++)
{
    Article a = new Article();
    a.Number = i;
    a.ArticleName = "Article" + i;
    a.Text = new List<ArticleText>();
    h.Articles.Add(a);

    for (int n = 1; n < 3; n++)
    {
        ArticleText t = new ArticleText();
        t.TextNumber = r;
        t.Text = "Text" + r + " for " + a.ArticleName;
        r++;
        a.Text.Add(t);
    }
}
this.CrystalReport11.SetDataSource(new List<Head>() { h });

hope someone can give me a hint what to do?

thx

Edited by: Mike Spass on Mar 9, 2012 10:25 AM

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Mar 09, 2012 at 05:33 PM

    I would start by not using groups, do you see all the records that you expect?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.