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

[Solved] Dynamic Columns

1 Answer 142 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Peter
Top achievements
Rank 1
Peter asked on 11 Feb 2014, 07:15 PM
Hi I'm trying to populate the Columns in a RadDataGrid, and am having trouble here.

I have a Dictionary<string, IList<object>>, where the string represents a column name, and the IList<object> is the items under that column.  I don't know what the column names are going to be until runtime.  Is there a way I can implement this?

Currently the AutoGenerateColumns assumes each property in an object is a column.  This makes it difficult to dynamically create columns at runtime.

Any help would be much appreciated!

Thanks

1 Answer, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 14 Feb 2014, 02:44 PM
Hello Peter,

Thank you for the question.

I suggest that you change the data structure that holds the items. The RadDataGrid needs a collection of ExpandoObject items. The ExpandoObject class implements the IDictionary<string, object> interface and for every item you will need to add a key-value pair with the name of the column and the corresponding cell value. I have attached a sample project that demonstrates how to do this.

I hope this helps. Please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
Grid for XAML
Asked by
Peter
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Share this question
or