Custom Clickable Component

Stimulsoft Reports.NET discussion
Post Reply
munishsethi
Posts: 20
Joined: Fri Jun 01, 2007 11:10 pm
Location: India

Custom Clickable Component

Post by munishsethi »


Respected Sir,

We are looking for a custom clickable component which we want to use in the following manner:-


a) User drags this custom component onto the report designer.

b) User then places a data field from a data source inside this custom component.

c) At the time of report generation, the data shows up inside this custom component.

d) Finally, we need to register a click handler so that when user will click on this custom component and we can get the value of the data field placed inside this component and use that value to take the user to a corresponding data element in our Application which hosts stimulsoft engine.


Any help on how to achieve it using a custom component will be appreciated.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Custom Clickable Component

Post by Edward »

munishsethi wrote:a) User drags this custom component onto the report designer.
Yes, it is possible. You can drag any column from the DataSource in the Dictionary in the report on the report page. But this actions intended to be proceed inside the designer. All this actions also can be proceed manually in code if you going to do all this actions without visualization.
Do you need to drag a component from outside the StiDesignerControl onto page inside of it?
munishsethi wrote:b) User then places a data field from a data source inside this custom component.
Is your component intended for displaying a text only, or an Image inside is also possible?
munishsethi wrote:c) At the time of report generation, the data shows up inside this custom component.
In design-time shows the expression in the format {DataSource.DataColumn}, in the runtime actual data.
munishsethi wrote:d) Finally, we need to register a click handler so that when user will click on this custom component and we can get the value of the data field placed inside this component and use that value to take the user to a corresponding data element in our Application which hosts stimulsoft engine.
We've added a static event
StiOptions.Engine.GlobalEvents.ComponentCreated
that fires when a component is placed on any container so you can add a custom processing of each StiText component.
This event is accessible in the build from October, 1.

Thank you.
munishsethi
Posts: 20
Joined: Fri Jun 01, 2007 11:10 pm
Location: India

Custom Clickable Component

Post by munishsethi »

Hi.
here is my response to your previous post..( in blue color)

a) User drags this custom component onto the report designer.
Yes, it is possible. You can drag any column from the DataSource in the Dictionary in the report on the report page. But this actions intended to be proceed inside the designer. All this actions also can be proceed manually in code if you going to do all this actions without visualization.
Do you need to drag a component from outside the StiDesignerControl onto page inside of it?

i am ok with this

munishsethi wrote:
b) User then places a data field from a data source inside this custom component.
Is your component intended for displaying a text only, or an Image inside is also possible?
We only need the ability to place a data field i.e. text inside this custom component


munishsethi wrote:
c) At the time of report generation, the data shows up inside this custom component.
In design-time shows the expression in the format {DataSource.DataColumn}, in the runtime actual data.
you are on right track with this point



munishsethi wrote:
d) Finally, we need to register a click handler so that when user will click on this custom component and we can get the value of the data field placed inside this component and use that value to take the user to a corresponding data element in our Application which hosts stimulsoft engine.
We've added a static event
StiOptions.Engine.GlobalEvents.ComponentCreated
that fires when a component is placed on any container so you can add a custom processing of each StiText component.
This event is accessible in the build from October, 1.

Actually we need the click handler in report preview mode and not in designer more. So when the report is previewed, we will take the user to actual record in our application when he clicks on our custom component.
munishsethi
Posts: 20
Joined: Fri Jun 01, 2007 11:10 pm
Location: India

Custom Clickable Component

Post by munishsethi »

Hi,

I hope our previous response is clear but if not, let me add some clarifications: -

Clarification on a) Yes, we are hoping we can register a custom compontent with stidesigner toolbar so that report designers can drag this componten onto designer, inside the data band. The user should then be able to drag a table field i.e. {table.columname} inside this component.

b) Our component is intended to display only text i.e. the value of the table column dragged inside the component.

c) Your understanding of intended behavior at report preview mode is correct. The compontent will simply display the column value just like any other field dragged in data band.

d) We want to register an OnClick event with this custom component that gets fired when the user clicks on this component in report preview mode. We would like the event to have the actual name and value of the field inside that component. The idea here is to identify the value of the column from that click event and take the user directly to a certain section of our application based on the field name and value inside the component.

This would really help us achieve our objectives with Stimulsoft. Please let us know if someting is still not clear.

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

Custom Clickable Component

Post by Edward »

munishsethi wrote:a) Yes, we are hoping we can register a custom compontent with stidesigner toolbar so that report designers can drag this componten onto designer, inside the data band. The user should then be able to drag a table field i.e. {table.columname} inside this component.
Yes, it is possible. Please see CustomComponent sample application from the standard delivery.
munishsethi wrote:b) Our component is intended to display only text i.e. the value of the table column dragged inside the component.
Yes, no problem. You can achieve the same behavior with your component as it realized with StiText component. When you are dragging a Column from the Dictionary onto existing StiText component on the page, its bounds is highlighted with red color and Text property becomes assigned to the dragged Column:

{DataSource.DataColumn}

Same behavior can be done with your component too.
munishsethi wrote:c) Your understanding of intended behavior at report preview mode is correct. The compontent will simply display the column value just like any other field dragged in data band.
d) We want to register an OnClick event with this custom component that gets fired when the user clicks on this component in report preview mode. We would like the event to have the actual name and value of the field inside that component. The idea here is to identify the value of the column from that click event and take the user directly to a certain section of our application based on the field name and value inside the component.
In the ClickEvent of your custom designed component you receive information about component which was clicked in the sender Parameter in the Preview mode. Also you can check the TextValue of the Component:
(sender as StiText).TextValue

But if you need to retrieve information about DataSource and DataColumn this text belongs, then store in Tag property this information, because in the Preview Mode this information is not accessible.

So if Tag property contains something like this:
DataSource.DataCloumn

and ClickEvent contains the following code:

MessageBox.Show((sender as CustomComponent.MyCustomComponent).TagValue.ToString());

then in the preview when you click on your component, then you can access the value, stored in the Tag: DataSource.DataCloumn.

Thank you.
munishsethi
Posts: 20
Joined: Fri Jun 01, 2007 11:10 pm
Location: India

Custom Clickable Component

Post by munishsethi »

Yes we have use your custom component sample application.

I can drag this custom component rectangle and then it asks for the text (displays a dialog box). This typed text is coming up on that component. Now here my requirement is that whatever text i wrote in this component(text property), it must also come in the tag property of this custom component.


Code of this custom component class is

Code: Select all


Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Imports Stimulsoft.Base
Imports Stimulsoft.Base.Drawing
Imports Stimulsoft.Base.Serializing
Imports Stimulsoft.Base.Services
Imports Stimulsoft.Base.Design
Imports Stimulsoft.Base.Localization
Imports Stimulsoft.Report.Components
Imports Stimulsoft.Report.Events
Imports Stimulsoft.Controls
Imports Stimulsoft.Report.Design
Imports Stimulsoft.Report.Design.StiDesigner
Imports Stimulsoft.Report.Dictionary
Imports Stimulsoft.Report.Components.Design

Namespace CustomComponent

     _
Public Class MyCustomComponent
        Inherits StiText
        Implements IStiBorder, IStiBrush

#Region "StiComponent override"
        ''' 
        ''' Gets value to sort a position in the toolbox.
        ''' 
        Public Overrides ReadOnly Property ToolboxPosition() As Integer
            Get
                Return 500
            End Get
        End Property

        ''' 
        ''' Gets a localized name of the component category.
        ''' 
        Public Overrides ReadOnly Property LocalizedCategory() As String
            Get
                Return StiLocalization.Get("Report", "Components")
            End Get
        End Property

        ''' 
        ''' Gets a localized component name.
        ''' 
        Public Overrides ReadOnly Property LocalizedName() As String
            Get
                Return "MyCustomComponent1"
            End Get
        End Property


        Public Overrides Property Text() As Stimulsoft.Report.Components.StiExpression
            Get
                Return MyBase.Text
            End Get
            Set(ByVal value As Stimulsoft.Report.Components.StiExpression)
                MyBase.Text = value
            End Set
        End Property

        Public Overrides Sub SetText(ByVal getValue As Object, ByVal value As String)
            MyBase.SetText(getValue, value)
        End Sub

#End Region

#Region "ICloneable override"
        ''' 
        ''' Creates a new object that is a copy of the current instance.
        ''' 
        ''' A new object that is a copy of this instance.
        Public Overloads Overrides Function Clone() As Object
            Return MyBase.Clone()
        End Function
#End Region

#Region "New"
        ''' 
        ''' Creates a new component of the type MyCustomComponent.
        ''' 
        Public Sub New()
            MyBase.New()
            'AddHandler Me.Click, AddressOf HandleClickEvent
        End Sub

        ''' 
        ''' Creates a new component of the type MyCustomComponent.
        ''' 
        ''' The rectangle describes size and position of the component.
        Public Sub New(ByVal rect As RectangleD)
            MyBase.New(rect)
            PlaceOnToolbox = True
        End Sub

        Public Sub New(ByVal rect As RectangleD, ByVal text As String)
            MyBase.New(rect, text)
        End Sub
#End Region

    Private Sub MyCustomComponent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
            MessageBox.Show(Me.TagValue.ToString)
            'CustomComponent.
        End Sub

    End Class
End Namespace

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

Custom Clickable Component

Post by Edward »

Yes, it is possible to achieve such a behavior. For this you should subscribe to TextProcess event and to make an assignment to the Tag property there.

Thank you.
Post Reply