Page 1 of 2

Find sibling components in a rendered DataBand-Row

Posted: Thu Sep 06, 2012 9:00 am
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

Re: Find sibling components in a rendered DataBand-Row

Posted: Thu Sep 06, 2012 12:26 pm
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.

Re: Find sibling components in a rendered DataBand-Row

Posted: Thu Sep 06, 2012 12:57 pm
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...

Re: Find sibling components in a rendered DataBand-Row

Posted: Fri Sep 07, 2012 9:58 am
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.

Re: Find sibling components in a rendered DataBand-Row

Posted: Fri Sep 07, 2012 10:32 am
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.

Re: Find sibling components in a rendered DataBand-Row

Posted: Mon Sep 10, 2012 8:26 am
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

Re: Find sibling components in a rendered DataBand-Row

Posted: Mon Sep 10, 2012 11:56 am
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.

Re: Find sibling components in a rendered DataBand-Row

Posted: Mon Sep 10, 2012 2:40 pm
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

Re: Find sibling components in a rendered DataBand-Row

Posted: Tue Sep 11, 2012 5:51 am
by Alex K.
Hello,

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

Thank you.

Re: Find sibling components in a rendered DataBand-Row

Posted: Tue Sep 11, 2012 11:24 am
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!