This question is locked. New answers and comments are not allowed.
I was unable to bind a DataTable to my MVC Chart control, so I converted the DataTable into an IEnumerable<Dictionary<string,object>> class. I am able to bind it to my chart now; however, I am unable to specify the value column for an indexed property!
I get the error:
Basically, I am stuck. How do I bind a DataTable to my MVC Chart control? If that is not possible, then how do I specify an indexed property of a dictionary that I have converted the DataTable to, in order to bind it to the Chart control!?
@(Html.Telerik().Chart(Model) .Name("chart") .Series(series => { series.Bar<string>(s => (string)s["Col1"]).Name("Representative Sales"); }) .CategoryAxis(axis => axis .Categories(s => s.Count) ))I get the error:
Bound columns require a field or property access expression.
Basically, I am stuck. How do I bind a DataTable to my MVC Chart control? If that is not possible, then how do I specify an indexed property of a dictionary that I have converted the DataTable to, in order to bind it to the Chart control!?
5 Answers, 1 is accepted
0
Hi Joh,
The chart does not support data table binding and I am not sure that you can bind it with Dictionary<string,object> too. Can you try to bind the chart with List of objects?
All the best,
Hristo Germanov
the Telerik team
The chart does not support data table binding and I am not sure that you can bind it with Dictionary<string,object> too. Can you try to bind the chart with List of objects?
All the best,
Hristo Germanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Viktor
Top achievements
Rank 1
answered on 21 May 2012, 07:52 PM
Please send example.
Thank you,
Thank you,
0
Hello John,
Hristo Germanov
the Telerik team
Could you please examine the attached project and tell me if it works for you.
Regards,Hristo Germanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
John
Top achievements
Rank 1
answered on 30 May 2012, 04:54 PM
Your example has a class in it that knows the property names ahead of time. The problem is that I will not know this information at design time since the data is coming from a stored procedure that the user specifies on his database. Therefore, you are able to specify one of these properties for the value/category, but I am unable to do that because I won't know them at compile time.
0
Hi John,
Hristo Germanov
the Telerik team
Can you examine this forum post and tell me if it works for you?
Regards,Hristo Germanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.