Feature Request for Data-binding in markup

2 posts, 0 answers
  1. Clint
    Clint avatar
    9 posts
    Member since:
    Oct 2011

    Posted 15 May 2015 Link to this post

    Right now the only way to do data-binding in the markup is to use NameField, DataFieldY, ColorField within the PieSeries tag. This requires a per record model. My current need requires a per field model such as with some of your other controls.

    You include an Items tag where each telerik:SeriesItem can be manually defined. If I could data-bind them, then I could do something such as:

        <telerik:SeriesItem NameField="A1" DataFieldY="B1" ColorField="C1" />
        <telerik:SeriesItem NameField="A2" DataFieldY="B2" ColorField="C2" />
        <telerik:SeriesItem NameField="A3" DataFieldY="B3" ColorField="C3" />

    To give some context my current usage is:

             RadHtmlChart + asp:Table

    So you see I need to be able to do the data within the chart all as one record. This works as I know I have a static amount of items for the PieSeries. Currently I've been doing this all in my codebehind as I can do a local pivot of a subset of each record and treat it as three separate records:

    DataTable chartData = GetChartData();
    radHtmlChart.DataSource = chartData;
    PieSeries pieChartSeries = new PieSeries();
    pieChartSeries.NameField = "Name";
    pieChartSeries.DataFieldY = "Percentage";
    pieChartSeries.ColorField = "Color";

    Now I know it's possible to bind my chart to a separate datasource, but I'd rather not do a whole new query. If there were a way to have a source use another source and pivot the data such as an adapter, then I'd be open to that as well. I'm still new to all of this on the markup side of things and haven't learned enough of the differences between a asp:SqlDataSource and telerik:RadClientDataSource for example.


  2. Danail Vasilev
    Danail Vasilev avatar
    1502 posts

    Posted 19 May 2015 Link to this post

    Hi Clint,

    Please find my comments and suggestions:
        - In order to bind the chart each series must refer to the corresponding data source field. This is done through the data-bound specific properties like DataFieldY, ColorField, etc.
        - The RadHtmlChart can be bound on the server-side as well as on the client-side. You can examine the server-side demos (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/databinding/database/defaultcs.aspx) as well as the client-side one (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/clientsidedatabinding/defaultcs.aspx). The asp:SqlDataSource control is used for a server-side data binding while the telerik:RadClientDataSource controls is used for a client-side data binding. The telerik:RadClientDataSource, however, is not integrated with the RadHtmlChart yet. Nevertheless you can bind the chart on the client-side as per the provided client-side demo.

    Danail Vasilev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top