dynamic add datasource to dictionary

Stimulsoft Reports.NET discussion
Post Reply
AllenZhang
Posts: 3
Joined: Fri Nov 25, 2016 3:23 am

dynamic add datasource to dictionary

Post by AllenZhang »

Hi,

Currently we are looking for a report engine to integrate to our own system, and I would like to choose Stimulsoft Reports.Net. When I was making proposal, I need add datasource to the report dictionary dynamicly, but I failed.
1.png
1.png (76 KiB) Viewed 3562 times
2.png
2.png (72.67 KiB) Viewed 3562 times
3.png
3.png (72.62 KiB) Viewed 3562 times
And here is the code, could you give me a help, thanks a lot.

Code: Select all

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

        StiReport report = new StiReport();

        private void Form1_Load(object sender, EventArgs e)
        {           
            StiOptions.Engine.GlobalEvents.DictionaryMenuEditOpenInDesigner += GlobalEvents_DictionaryMenuEditOpenInDesigner;
      
            report.Design(true);
            report.Compile();                     
        }

        private void GlobalEvents_DictionaryMenuEditOpenInDesigner(object sender, EventArgs e)
        {
            var t = sender as Stimulsoft.Controls.Win.DotNetBar.ButtonItem;

            Stimulsoft.Controls.Win.DotNetBar.ButtonItem btnNewDb = new Stimulsoft.Controls.Win.DotNetBar.ButtonItem();
            btnNewDb.Text = "Add My DataSource";
            btnNewDb.Name="btnNewDb";
            btnNewDb.Click += btnNewDb_Click;
            
            if(!t.SubItems.Contains("btnNewDb"))
            {
                t.SubItems.Add(btnNewDb);
            }           
        }

        private void btnNewDb_Click(object sender, EventArgs e)
        {
            report.Dictionary.Clear();

            DataSet ds = new DataSet("CustomerDatasource");
            DataTable dt1 = new DataTable();
            dt1.Columns.Add(new DataColumn("c1", typeof(int)));
            dt1.Columns.Add(new DataColumn("c2", typeof(string)));

            DataTable dt2 = new DataTable();
            dt2.Columns.Add(new DataColumn("c3", typeof(int)));
            dt2.Columns.Add(new DataColumn("c4", typeof(string)));

            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);

            report.Dictionary.ImportXMLSchema(ds);

            report.Dictionary.Synchronize();

            report.Compile();
        }        
    }
The project attached below:
WindowsFormsApplication1.zip
(76.83 KiB) Downloaded 230 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: dynamic add datasource to dictionary

Post by Alex K. »

Hello,

Please check the modified project in the attachment.

Thank you.
Attachments
WindowsFormsApplication1.zip
(96.3 KiB) Downloaded 220 times
AllenZhang
Posts: 3
Joined: Fri Nov 25, 2016 3:23 am

Re: dynamic add datasource to dictionary

Post by AllenZhang »

Hi Aleksey,
Thank you very much for your reply.
I saw the demo you provided, but i get this error:

can not finde the method --> designer.GetDictionaryService()

There is a reference to Stimulsoft.Report.Import.dll.
This dll is not contained in the Stimulsoft-Reports-Ultimate-2016.1-Pack-Trial?
Does the product version contain the dll?

Thanks very much!

Allen
Aleksey wrote:Hello,

Please check the modified project in the attachment.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: dynamic add datasource to dictionary

Post by Alex K. »

Hello,

Please check the last version 2016.2.
The GetDictionaryService() was added after 2016.1 version.

Thank you.
AllenZhang
Posts: 3
Joined: Fri Nov 25, 2016 3:23 am

Re: dynamic add datasource to dictionary

Post by AllenZhang »

Hi Aleksey,

Thank you very much!

Allen
Aleksey wrote:Hello,

Please check the last version 2016.2.
The GetDictionaryService() was added after 2016.1 version.

Thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: dynamic add datasource to dictionary

Post by Alex K. »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
ramezani@pre.nl
Posts: 2
Joined: Tue Nov 20, 2018 10:49 am

Re: dynamic add datasource to dictionary

Post by ramezani@pre.nl »

I have the same problem. I am using .Net Core version through Web API. Therefore I can not access "StiRibbonDesignerControl". I already added "using Stimulsoft.Report.Import;" but still not working

Code: Select all

public string CreateReportTemplate()
        {
            StiReport report = new StiReport();
            StiRibbonDesignerControl designer = new StiRibbonDesignerControl();

            report.Dictionary.Clear();

            DataSet ds = new DataSet("CustomerDatasource");
            DataTable dt1 = new DataTable();
            dt1.Columns.Add(new DataColumn("c1", typeof(int)));
            dt1.Columns.Add(new DataColumn("c2", typeof(string)));

            DataTable dt2 = new DataTable();
            dt2.Columns.Add(new DataColumn("c3", typeof(int)));
            dt2.Columns.Add(new DataColumn("c4", typeof(string)));

            ds.Tables.Add(dt1);
            ds.Tables.Add(dt2);

            report.RegData(ds);
            report.Dictionary.Synchronize();
            designer.Report = report;

            var stiDictionaryPanelService = designer.GetDictionaryService();
            stiDictionaryPanelService.BuildDictionary();
        }
Lech Kulikowski
Posts: 6263
Joined: Tue Mar 20, 2018 5:34 am

Re: dynamic add datasource to dictionary

Post by Lech Kulikowski »

Hello,

This code for NET, Wpf version but you use .Net Cor. Stimulsoft.Report.Import is not present in Web versions.
Maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.
Post Reply