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

[Solved] Display dynamic objects in grid

4 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stephan
Top achievements
Rank 1
Stephan asked on 05 Aug 2010, 01:24 PM
Hi,

I was wondering if somebody could tell me whether I have found a bug, or am using the MVC Grid wrong.  I have created a copy of dynamic objects in the controller :
List<dynamic> data = new List<dynamic>();
   dynamic item1 = new ExpandoObject();
   item1.FirstName = "First1";
   item1.SecondName = "Second1";
   dynamic item2 = new ExpandoObject();
   item2.FirstName = "First2";
   item2.SecondName = "Second2";
   data.Add(item1);
   data.Add(item2);

and I also created a couple of columns to display the information in the grid

var columns = new[] 
 
     new GridColumnSettings { Member = "FirstName", Width = "130px", Title="First" }, 
     new GridColumnSettings { Member = "SecondName", Width = "130px", Title="Second" }
 }; 

I then placed these into my ViewModel
viewModel.Data = data;
viewModel.Columns = columns;
where viewModel is
public class MyViewModel
 {
     public List<dynamic> Data { get; set; }
     public IEnumerable<GridColumnSettings> Columns { get; set; }
 }

then this is past to the page and the grid as :
<%: Html.Telerik().Grid( Model.Data )
    .Name("Grid")
    .Sortable()
    .Scrollable()
    .Pageable()
    .Columns(Model.Columns)
    %>

I then get the following error at runtime
Invalid property or field - 'FirstName' for type: Object

If somebody could help me and let me know where I'm going wrong that would be brilliant.

Stephan

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 Aug 2010, 01:48 PM
Hello Stephan,

The grid does not support binding to dynamic objects for the time being. We will look into supporting it for a future release.

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Erik
Top achievements
Rank 2
answered on 08 Sep 2010, 06:59 PM
Hi,

I was just looking for this.

Would be a plus for me!

Regards,

Erik
0
Erik
Top achievements
Rank 2
answered on 19 Dec 2010, 03:58 PM
any news yet?
0
Nich
Top achievements
Rank 1
answered on 19 Dec 2010, 06:28 PM
I'm using this with the 2010Q3 release and MVC3 (RC2)...

I'm passing IEnumerable<dynamic> as a Model into my view, and it's all working nicely!

You have to have MVC3 to allow dynamic models, though, I think.


Nich
Tags
Grid
Asked by
Stephan
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Erik
Top achievements
Rank 2
Nich
Top achievements
Rank 1
Share this question
or