Page 1 of 1

trouble showing fields in dictionary

Posted: Tue May 13, 2008 5:22 am
by dj_uvdata
Hi I have a problem showing all fields from the datasoruce in the Dictionary treeview.

I create a report with the following code:

Code: Select all

            StiReport report = new StiReport();            
            Datasource d = new Datasource();
            List list = new List();
            Team t1 = new Team("Team 1");
            t1.list.Add(new Child("c1a_firstname", "b1a_lastname"));
            t1.list.Add(new Child("c1b_firstname", "b1b_lastname"));

            Team t2 = new Team("Team 2");
            t2.list.Add(new Child("c2a_firstname", "b2a_lastname"));
            t2.list.Add(new Child("c2b_firstname", "b2b_lastname"));
            
            list.Add(t1);
            list.Add(t2);
            d.list = list;                      
            report.RegData("Data",d);
            report.Dictionary.Synchronize();
            report.Design();
Classes I am using in the code above:

Code: Select all

    public class Datasource
    {
        public List list = new List();
    }

    public class Team
    {
        public string Name { set; get; }
        public List list = new List();

        public Team(string name)
        {
            Name = name;
        }
    }

    public class Child
    {
        public Child(string firstnames, string lastname)
        {
            Firstnames = firstnames;
            Lastname = lastname;            
        }
        public string Firstnames { set; get; }
        public string Lastname { set; get; }
    }

The problem is that I only show a field name "Data". I want to see the entire tree stucture of the datasource in the dictionary of the designer.

What can I do to make this possible?

Thank you.

trouble showing fields in dictionary

Posted: Tue May 13, 2008 1:02 pm
by Edward
Please add the following code before RegData():

StiOptions.Dictionary.BusinessObjects.AllowUseFields = true;

Thank you.

trouble showing fields in dictionary

Posted: Wed May 14, 2008 1:53 am
by dj_uvdata
That did the trick - except no data is shown at design time.

Do you know what is needed here?

Thank you

trouble showing fields in dictionary

Posted: Wed May 14, 2008 5:18 pm
by Edward
Please modify your code as follows:

Code: Select all

public class Datasource
{
    private List list;
    public List List 
    {
        get { return list; }
        set { value = list;}
    }
    public Datasource()
    {
        list = new List();
    }                       
}

public class Team
{
    private string name;

    public string Name
    {
        set {name = value;}
        get {return name;}
    }

    private List list;

    public List List
    {
        set {list = value;}
        get {return list;}
    }


    public Team(string name)
    {
        Name = name;
        List = new List();
    }
}

public class Child
{
    private string firstNames;
    private string lastNames;

    public Child(string firstnames, string lastname)
    {
        Firstnames = firstnames;
        Lastname = lastname;           
    }
    public string Firstnames { set {firstNames = value;} get {return firstNames;} }
    public string Lastname { set { lastNames = value; } get { return lastNames; } }
}

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        StiOptions.Dictionary.BusinessObjects.AllowUseProperties = true;

        StiReport report = new StiReport();           
        Datasource d = new Datasource();
        //List list = new List();
        List list = d.List;
        Team t1 = new Team("Team 1");
        t1.List.Add(new Child("c1a_firstname", "b1a_lastname"));
        t1.List.Add(new Child("c1b_firstname", "b1b_lastname"));

        Team t2 = new Team("Team 2");
        t2.List.Add(new Child("c2a_firstname", "b2a_lastname"));
        t2.List.Add(new Child("c2b_firstname", "b2b_lastname"));
       
        list.Add(t1);
        list.Add(t2);
        //d.List = list;
        report.RegData("Data",d);
        report.Dictionary.Synchronize();
        report.Design();
    }
If some fields in your classes can not be converted into properties, then add the following string:

StiOptions.Dictionary.BusinessObjects.AllowUseFields = true;

Possible nesting of Business Objects level is regulated with the following parameter:

StiOptions.Dictionary.BusinessObjects.MaxLevel

Thank you.

trouble showing fields in dictionary

Posted: Tue May 27, 2008 3:07 am
by dj_uvdata
After some study I discovered that the example does not work.

What is missing are the relations in the dictionary. How can I define those dynamic?

I went through the BusinessObjects sampe in the Stimulsoft package. You relations are hardcoded directly in the report mht. file and not in the cs file where the datasource is defined. That can surely not be the correct way to do it?

Thank you

trouble showing fields in dictionary

Posted: Tue May 27, 2008 8:52 am
by dj_uvdata
The following source code is my idea on how to add relations and restrictions. Is this the correct approach?

Thank you

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Stimulsoft.Report;
using System.Collections;
using System.Reflection;
using Stimulsoft.Report.Dictionary;

namespace stireportTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            StiReport report = new StiReport();            

            StiOptions.Dictionary.BusinessObjects.AllowUseProperties = true;
            StiOptions.Dictionary.BusinessObjects.AllowUseFields = false;
            StiOptions.Dictionary.BusinessObjects.MaxLevel = 3;
            
            var d = MkDatasource();
            report.RegData(d.GetType().Name, d);
            report.Dictionary.Synchronize();
            
            for(int i = 0;i Teamliste { get; set; }    
    
    public Datasource(string kilde) 
    {        
        Datakilde = kilde; 
        Teamliste = new List();
        Relationer = new List();
        RestriktionerKilde = new List();
        RestriktionerKolonne = new List();
    }

    public List Relationer { get; set; }
    public List RestriktionerKilde { get; set; }
    public List RestriktionerKolonne { get; set; }
}

public class Team
{
    private string name;
    public string Name
    {
        set { name = value; }
        get { return name; }
    }

    public List Childliste { get; set; }

    public Team(string name)
    {
        Name = name;
        Childliste = new List();
    }
}

public class Child
{
    private string firstNames;
    private string lastNames;
    
    public Child(string firstnames, string lastname)
    {
        Firstnames = firstnames;
        Lastname = lastname;
    }
    public string Firstnames { set { firstNames = value; } get { return firstNames; } }
    public string Lastname { set { lastNames = value; } get { return lastNames; } }
}


trouble showing fields in dictionary

Posted: Tue May 27, 2008 11:24 am
by Brendan
The relations should be created automatically when using the code Edward posted.

You should have 3 tables in the datasource. Data , Data_List and Data_List_List
Data_List should have a relation to Data and Data_List_List should have a relation to Data_List

Does this not happen for you?

trouble showing fields in dictionary

Posted: Tue May 27, 2008 11:42 am
by Edward
I just have finished checking of the new code that dj_uvdata posted recently. It really adds relations to the appropriate DataSources. Together with automatically created relations I had also relations which were added 'by hand' in that code.

If something was wrong with registering of the data , then it wasn't connected with automatically generated relations from business objects in the above solutions. You really do not need to register relations additionally.

Thank you.

trouble showing fields in dictionary

Posted: Tue May 27, 2008 6:09 pm
by Edward
Yes, it is the issue with latest prerelease build.

Thank you for your feed back.

We'll post a message in this topic when the solution is ready.

Thank you.