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

Databound source - Conditional item binding (and/or editing)

1 Answer 108 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Wendelstam
Top achievements
Rank 1
Wendelstam asked on 21 Apr 2015, 01:37 PM

Hi.
I am porting an old applications chart section from RadChart to RadHtml chart and am struggeling with how to edit serie items prior to rendering. The main problem is that since we are binding against an list of objects where some integer properties contains -1 values (which in our context means NULL/UNDEFINED). I cannot change this behaviour of the object since the system heavily rely on that fact.

When using RadChart we could "hook into" the series items in the ItemDataBound event. See example below.

How can I achieve the same thing with RadHtmlChart ?

BR
Johan

           

var columnInfo = _basicReportsPresenter.GetColumnInfoByName(e.ChartSeries.DataYColumn);
 
if (!columnInfo.ColumnInfoAttribute.DisplayNegativeValues)
{
    if (e.SeriesItem.YValue < 0)
    {
        if (_enableEmptyValues)
            e.SeriesItem.Empty = true;
        e.SeriesItem.YValue = 0;
    }
}

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 23 Apr 2015, 07:59 AM
Hi Johan,

RadHtmlChart doesn't support a server-side ItemDataBound event because it renders entirely on the client-side. More information is available here - http://www.telerik.com/help/aspnet-ajax/htmlchart-troubleshooting-known-limitations.html

I can suggest that you try one of the following approaches:
    - Change the data source values prior to the data-binding on the server-side.
    - Change the data source on the client-side through the $find("RadHtmlChart1").get_dataSourceJSON() and $find("RadHtmlChart1").set_dataSource() methods. More information is available here - http://www.telerik.com/help/aspnet-ajax/htmlchart-client-side-api.html
    - Iterate through series and items on the client-side and change the corresponding values. You can access series items values like that:
$find("RadHtmlChart1").get_kendoWidget().options.series[0].data[0].myDataSourceField= 10;
$find("RadHtmlChart1").get_kendoWidget().redraw();


Regards,
Danail Vasilev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

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