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

Feature Request for Data-binding in markup

1 Answer 47 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Clint
Top achievements
Rank 1
Clint asked on 15 May 2015, 11:09 PM

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!

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 19 May 2015, 06:20 AM
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
Tags
Chart (HTML5)
Asked by
Clint
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or