Radchart click event not working as expected

Thread is closed for posting
4 posts, 0 answers
  1. Pena
    Pena avatar
    4 posts
    Member since:
    Jun 2011

    Posted 30 Aug 2011 Link to this post

    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.

  2. Evgenia
    Admin
    Evgenia avatar
    1407 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pena
    Pena avatar
    4 posts
    Member since:
    Jun 2011

    Posted 02 Sep 2011 Link to this post

    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

     

  5. Missing user
    Missing user avatar

    Posted 08 Sep 2011 Link to this post

    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 >>

Back to Top