Pass KeyValue?

3 posts, 1 answers
  1. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 31 Mar 2014 Link to this post

    Column Chart

    I am working through the drill down chart example and all is great, but I want is to show the title of the product in the 'DataLabelsField' but pass the productID value when I click the column. 

    I'm passing the value client side 
    function OnClientSeriesClicked(sender, args) {
                      if (args.get_seriesName() != "Orders") $find("<%= rapD.ClientID %>").ajaxRequest(args.get_category());
                  }

    My SQLDataSource has productID, ProductName and a count field.

    I've been searching for ages now but can't find a solution to what must be simple.

    Cheers,

    Jon
  2. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 01 Apr 2014 Link to this post

    Hello Jon,

    You can obtain data source field values on the client-side click/hover event handler through the get_dataItem() method (see OnClientSeriesClicked help article). Once you obtain the desired value you can concatenate it with all of the desired arguments in a common string with particular delimiter and send it back to the server, where the string can be split into the actual arguments. For example:

    JavaScript:
        function OnClientSeriesClicked(sender, args) {
            var arg2 = args.get_dataItem().Year;
            if (args.get_seriesName() != "Months") $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest(args.get_category()+ "|" + arg2);
    }
    C#:
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            string seriesName = RadHtmlChart1.PlotArea.Series[0].Name;
            string[] arguments = e.Argument.Split('|');
            if (seriesName == "Years")
            {          
                Year = int.Parse(arguments[0]);
                SqlDataSource2.SelectParameters[0].DefaultValue = Year.ToString();
                RadHtmlChart1.PlotArea.XAxis.DataLabelsField = "Quarter";
                RadHtmlChart1.PlotArea.Series[0].DataFieldY = "Rev";
                RadHtmlChart1.PlotArea.Series[0].Name = "Quarters";
                RadHtmlChart1.DataSourceID = "SqlDataSource2";
            }
    ...
        }


    Regards,
    Danail Vasilev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jack
    Jack avatar
    128 posts
    Member since:
    May 2003

    Posted 01 Apr 2014 in reply to Danail Vasilev Link to this post

    Beautiful Danail,

    Thank you very much!

    Jon
Back to Top