Click Event for sub report

Stimulsoft Reports.NET discussion
ymc
Posts: 31
Joined: Tue Oct 30, 2007 9:00 pm
Location: Hong Kong

Click Event for sub report

Post by ymc »

I have some requests from client about:

1. They want to display some data in the form of bar chart and during double click on the specific bar then display the detail. My idea is about can I just have a double click event and then rendering another report or enable the pre-rendered page to display? Any idea which method is possible to get the result.

2. The request is nearly the same as above but this time is click on the row and pass the value to render another report base on the clicked row data?

Thx.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Click Event for sub report

Post by Vital »

Hello,
1. They want to display some data in the form of bar chart and during double click on the specific bar then display the detail. My idea is about can I just have a double click event and then rendering another report or enable the pre-rendered page to display? Any idea which method is possible to get the result.
At this moment this is not possible.
2. The request is nearly the same as above but this time is click on the row and pass the value to render another report base on the clicked row data?
Yes, it possible. Please see sample project LiveReports from standard delivery.

Thank you.
mihiri
Posts: 13
Joined: Thu Jun 12, 2008 4:43 am
Location: Manama,bahrain

Click Event for sub report

Post by mihiri »

Would you please explain how case 2 is done, this example is not clear to me..
Thank you in advance
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Click Event for sub report

Post by Vital »

Hello,
mihiri wrote:Would you please explain how case 2 is done, this example is not clear to me..
Thank you in advance
Each component in report have filled Bookmark property (or Tag property). This value used as parameters for detail reports. Before report running we have signed to Click event of
report:

Code: Select all

report.CompiledReport.Click += new EventHandler(click);
In event handler of this event we use following code:

Code: Select all

private void click(object sender, EventArgs e)
		{
                        //Component which generate click event
			StiComponent comp = sender as StiComponent;
                        //Our parameter
			string customerID = (string)comp.BookmarkValue;
            
                        //Run report with parameter
			if (customerID != null)
			{
				StiReport report = new StiReport();
				report.RegData(dataSet1);
				report.Load("..\\..\\Details.mrt");
				StiDataBand dataBand = (StiDataBand)report.Pages["Page1"].Components["DataBand1"];
                                //Parameter assigned to databand filter
				dataBand.Filter.Value = "{Orders.CustomerID==\"" + customerID + "\"}";
				report.Show();
			}
		} 
Thank you.
mihiri
Posts: 13
Joined: Thu Jun 12, 2008 4:43 am
Location: Manama,bahrain

Click Event for sub report

Post by mihiri »

thanks a lot for your detailed description. But this code is not available in the
"C:\Program Files\Stimulsoft Reports.Net 2007.3\.Net 2.0\Samples\C#\LiveReports\LiveReports.mrt"
am I browsing the wrong place?
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Click Event for sub report

Post by Vital »

Hello,

Please see code of Form1.cs.

Thank you.
Pio Leonardo V. Rapirap
Posts: 7
Joined: Wed Nov 26, 2008 1:40 am
Location: Philippines

Click Event for sub report

Post by Pio Leonardo V. Rapirap »

Had a look at this code:

Code: Select all

private void click(object sender, EventArgs e)
        {
                        //Component which generate click event
            StiComponent comp = sender as StiComponent;
                        //Our parameter
            string customerID = (string)comp.BookmarkValue;
           
                        //Run report with parameter
            if (customerID != null)
            {
                StiReport report = new StiReport();
                report.RegData(dataSet1);
                report.Load("..\\..\\Details.mrt");
                StiDataBand dataBand = (StiDataBand)report.Pages["Page1"].Components["DataBand1"];
                                //Parameter assigned to databand filter
                dataBand.Filter.Value = "{Orders.CustomerID==\"" + customerID + "\"}";
                report.Show();
            }
        } 
tried it, and successfully duplicated this one.


Hi! just a quick question.

how would it work if instead of loading an mrt file,
we load a compiled report instead

Code: Select all

report = StiReport.GetReportFromAssembly("Detail.dll");
is Filtering a databand value same as

Code: Select all

dataBand.Filter.Value = "{Orders.CustomerID==\"" + customerID + "\"}"; 
I tried this statement (although I know it wouldn't work)

Code: Select all

		StiDataBand dataBand = report.CompiledReport.GetComponents()["DatadsProject"] as StiDataBand;
		dataBand.Filter.Value = "{dsProject.busent== " + strBusEnt + "}";
it's obviously incorrect and honestly I don't have any idea how to do it :pffft:

Any Thoughts?!
Is it possible to create a parameter inside the Detail.mrt
and pass a value from it?

Are parameters accessible inside a compiled report? (dll) :byebye:

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

Click Event for sub report

Post by Edward »

Hello.
PLR wrote:how would it work if instead of loading an mrt file,
we load a compiled report instead
In that case the filter could be created with help of variables. This variables can be set before rendering and filters will work as expected.

Please make the following steps:

- Create MyVariable variable in the Dictionary.

- Set the Filter asexpression in the Designer as following:

Code: Select all

Orders.CustomerID==MyVariable
- before calling Render() or Show() command, assign the variable in the compiled report:

Code: Select all

myCompiledReport["MyVarialbe"] = 5;
Thank you.
Pio Leonardo V. Rapirap
Posts: 7
Joined: Wed Nov 26, 2008 1:40 am
Location: Philippines

Click Event for sub report

Post by Pio Leonardo V. Rapirap »

Edward wrote:Hello.
PLR wrote:how would it work if instead of loading an mrt file,
we load a compiled report instead
In that case the filter could be created with help of variables. This variables can be set before rendering and filters will work as expected.

Please make the following steps:

- Create MyVariable variable in the Dictionary.

- Set the Filter asexpression in the Designer as following:

Code: Select all

Orders.CustomerID==MyVariable
- before calling Render() or Show() command, assign the variable in the compiled report:

Code: Select all

myCompiledReport["MyVarialbe"] = 5;
Thank you.
Worked like a charm!
:blush: Great Thanks Edward!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Click Event for sub report

Post by Edward »

Hello

Please let us know if any help is required.

Thank you.
Post Reply