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

2 posts, 0 answers
  1. Wendelstam
    Wendelstam avatar
    48 posts
    Member since:
    Feb 2006

    Posted 21 Apr 2015 Link to this post

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

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 23 Apr 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top