This question is locked. New answers and comments are not allowed.
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 :
I then placed these into my ViewModel
where viewModel is
then this is past to the page and the grid as :
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
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; 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) %>
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