This is a migrated thread and some comments may be shown as answers.

Radchart click event not working as expected

3 Answers 108 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Pena
Top achievements
Rank 1
Pena asked on 30 Aug 2011, 05:26 PM
Hello,

I would like to open a Pop up window when clicked on chart title.. I have used Javascript function to open the pop-up.

 

function ShowPopUpDialog() {
            window.open('Details.aspx', 'ChartDetails', 'height = 300px, width = 300px', true);
        }

  

 Here is the call to Javascript function from chart click event

  

 

Protected Sub RadChart2_Click(ByVal sender As Object, ByVal args As Telerik.Charting.ChartClickEventArgs) Handles RadChart2.Click
      Session("ChartReference") = "AccountSize"
      RadChart2.ChartTitle.ActiveRegion.Url = "javascript:ShowPopUpDialog();"
  End Sub

When I clicked on the chart Title the first time, I see that it is triggering a javascript:_doPostback event instead of my function... It works fine as expected from second click onwards..(after the postback)
Any help to resolve this behavior is appreciated

Thanks.

3 Answers, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 02 Sep 2011, 01:16 PM
Hello Pena,

Why don't you use the server events we provide to open the pop-up? For example you can use the fact that Chart Title has ActiveRegion.Click event that you may wire to. For more information and samples - you can review our help topic as well as this online demo.

Greetings,
Evgenia
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Pena
Top achievements
Rank 1
answered on 03 Sep 2011, 01:53 AM
Hi Evgenia,

I am still having the same issue after trying out the code in the links referred by you...

In the below code, as soon as I click the chart title,  I get the message box but I am NOT redirected to Details.aspx page..Instead my current page just refreshes as if it is doing a post back..

When clicked theChart title second time it works fine.. It appears that chart performs  a postback for the 1st click and then it works as expected..

So this does not seem to be related to using Javascript  A faster reply is appreciated as I am fighting with this issue for a while. Thanks.

 

 

Protected Sub RadChart2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadChart2.Load
  
AddHandler RadChart2.ChartTitle.ActiveRegion.Click, AddressOf Region_Click
  
End Sub
  
Sub Region_Click(ByVal sender As Object, ByVal args As RegionClickEventArgs)
  
'Dim logFormat As String = "Item Class:{0} - ""{1}""" + Environment.NewLine
  
If TypeOf sender Is ChartTitle Then
  
Dim MyChart As ChartTitle = TryCast(sender, ChartTitle)
  
Dim logFormat As String = "Item Class:{0} - ""{1}""" + Environment.NewLine
  
If TypeOf sender Is ChartTitle Then
  
MsgBox([String].Format(logFormat, sender.[GetType]().Name, (TryCast(sender, ChartTitle)).TextBlock.Text))
  
RadChart2.ChartTitle.ActiveRegion.Url = "Details.aspx"
  
End If
  
 
  
End If
  
End Sub

 

0
Missing User
answered on 08 Sep 2011, 08:00 AM
Hi Pena,

The described behavior occurs because you set the ChartTitle.ActiveRegion.Url after the region is clicked -- in ChartTitle.ActiveRegion.Click event. That is why on first click there is no url set for the ChartTitle active region and you are not redirected to the other page. You can set the ChartTitle.ActiveRegion.Url at an earlier stage, e.g. in RadChart.Load event:
Protected Sub RadChart2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadChart2.Load
    RadChart2.ChartTitle.ActiveRegion.Url = "Details.aspx"
    AddHandler RadChart2.ChartTitle.ActiveRegion.Click, AddressOf Region_Click
End Sub
   
Sub Region_Click(ByVal sender As Object, ByVal args As RegionClickEventArgs)
    If TypeOf sender Is ChartTitle Then
        Dim MyChart As ChartTitle = TryCast(sender, ChartTitle)
        Dim logFormat As String = "Item Class:{0} - ""{1}""" + Environment.NewLine
   
        If TypeOf sender Is ChartTitle Then
            MsgBox([String].Format(logFormat, sender.[GetType]().Name, (TryCast(sender, ChartTitle)).TextBlock.Text))
        End If
    End If
End Sub

I hope this helps.

All the best,
Polina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Chart (Obsolete)
Asked by
Pena
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Pena
Top achievements
Rank 1
Missing User
Share this question
or