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:

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

    To give some context my current usage is:

    RadPanelBar
       ItemTemplate
          Panel
             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;
    radHtmlChart.DataBind();
     
    PieSeries pieChartSeries = new PieSeries();
    pieChartSeries.NameField = "Name";
    pieChartSeries.DataFieldY = "Percentage";
    pieChartSeries.ColorField = "Color";
    radHtmlChart.PlotArea.Series.Add(pieChartSeries);

    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.

     Thanks!

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1493 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.

    Regards,
    Danail Vasilev
    Telerik
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top