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

Pass KeyValue?

2 Answers 57 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 31 Mar 2014, 03:39 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Danail Vasilev
Telerik team
answered on 01 Apr 2014, 01:26 PM
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.

 
0
Jon
Top achievements
Rank 1
answered on 01 Apr 2014, 04:08 PM
Beautiful Danail,

Thank you very much!

Jon
Tags
Chart (HTML5)
Asked by
Jon
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Jon
Top achievements
Rank 1
Share this question
or