Find sibling components in a rendered DataBand-Row

Stimulsoft Reports.WPF discussion
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Find sibling components in a rendered DataBand-Row

Post by tpontow »

Hello,

how can i get access to all sibling components in a rendered StiDataBand?

After the Databand is rendered (EndRender-Event) i attached a ClickEvent-Handler to all Components. When clicking on a rendered component i like to get access to all sibling components in the same rendered row.

All i get is access to the Parent component which here is the current page. From that page component i can find ALL components of the page which is way too much. I need only to find the related components of the same row.

Any suggestions or solutions?

Kind regards
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Find sibling components in a rendered DataBand-Row

Post by HighAley »

Hello.

If we understand you correctly, you should use drill-down reports.
Please, try to watch our videos where you could learn how to build Drill-down reports. You could find them on our site http://www.stimulsoft.com/en/videos
Also look at the Interactive Reports section of our Demo.

Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Find sibling components in a rendered DataBand-Row

Post by tpontow »

Hi,

the Drill-Down report is unfortunately not what i need here. My final goal in the end is to find the business object used for rendering the data row where the component i've clicked on is embedded.

I know i can go through the rows with DataBand.First() / DataBand.Next() and then check the DataBand.BusinessObject.Current property. But maybe there is better way?

Thanks...
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Find sibling components in a rendered DataBand-Row

Post by HighAley »

Hello.

We don't enough understand your problem.
Could you explain your situation more detailed if it's possible with examples.

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

Re: Find sibling components in a rendered DataBand-Row

Post by Alex K. »

Hello,
tpontow wrote:I know i can go through the rows with DataBand.First() / DataBand.Next() and then check the DataBand.BusinessObject.Current property. But maybe there is better way?
As a way, you can use in the Tag property (Interaction - Tag):
DataBand.BusinessObject.Current
and then you can use the TagValue property.

Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Find sibling components in a rendered DataBand-Row

Post by tpontow »

Hallo Aleksey,

I cannot find any data in the Interaction property. For every component i am clicking on the Interaction property is null. Do you have any samples for the use of Interaction in context with BusinessObjects?

All i need is the information which business data is used for rendering a certain report row when clicking on a report component in this row in preview.

Thanks
Thorsten
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Find sibling components in a rendered DataBand-Row

Post by Alex K. »

Hello,

Sorry for mistake. In this case, you can use the following expression in the GetTag event instead the property Tag(Interaction):

Code: Select all

e.Value = DataBand2.BusinessObject.Current;
and then you can use the following code in Click events (as example):

Code: Select all

string s = ((DataRow)((StiText)sender).TagValue)["ProductID"].ToString() + " \n" +
	((DataRow)((StiText)sender).TagValue)["ProductName"].ToString() + " \n" +
	((DataRow)((StiText)sender).TagValue)["UnitPrice"].ToString();
MessageBox.Show(s);
Please see the sample report in attachment.

Let us know if you need any additional help.
Thank you.
Attachments
SampleDetailBusinessObjects.mrt
(24.3 KiB) Downloaded 361 times
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Find sibling components in a rendered DataBand-Row

Post by tpontow »

Hallo Aleksey,

thanks for your quick response. Your last post provided me with the missing information. So it solved my problem and everything works fine now.

With that i understand now better how everything works together.

Thanks again
Thorsten Pontow
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Find sibling components in a rendered DataBand-Row

Post by Alex K. »

Hello,

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

Thank you.
User avatar
tpontow
Posts: 206
Joined: Thu Sep 06, 2012 8:46 am
Location: Bonn, Germany

Re: Find sibling components in a rendered DataBand-Row

Post by tpontow »

Code for my solution now is as follows:
  • Register Click- and GetTag-Events for all StiText instances in the DataBand after report is loaded and compiled.

    Code: Select all

                
                StiReport report = new StiReport();
                report.RegBusinessObject("test","test", dataSource);
     
                report.Load(@"...");
                report.Compile();
                
                //m_dataBand is local class variable.
                m_dataBand = report.CompiledReport.GetComponents()["DataBand1"] as StiDataBand;
    
                if (!ReferenceEquals(m_dataBand, null))
                {
                    foreach (var component in m_dataBand.GetComponents())
                    {
                        StiText text = component as StiText;
                        if (!ReferenceEquals(text, null))
                        {
                            text.GetTag += ComponentGetTag;
                            text.Click += ComponentClick;
                        }
                    }
                }
    
  • Assign current rendered business object in GetTag-EventHandler to StiValueEventArgs.Value

    Code: Select all

    void ComponentGetTag(object sender, Stimulsoft.Report.Events.StiValueEventArgs e)
            {
                e.Value = m_dataBand.BusinessObject.Current;
            }
  • In Click-EventHandler use the TagValue of StiText

    Code: Select all

    void ComponentClick(object sender, System.EventArgs e)
            {
                StiText text = sender as StiText;
                if (!ReferenceEquals(text, null))
                {
                    string tagValueString= text.TagValue.ToString();
                    MessageBox.Show(tagValueString);
                }
            }
And that's it!
Thorsten Pontow

It is easier to write an incorrect program than to understand a correct one. (Alan J. Perlis, Epigrams in programming No. 7)
Post Reply