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

[Solved] Model with dynamic properties

0 Answers 43 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.
Cristian
Top achievements
Rank 1
Cristian asked on 10 Jun 2011, 07:27 PM
Does the MVC Grid support showing dynamic properties from a DynamicObject model?

Let me explain my scenario.  This is a sample model:
Public Class ModelX
    Inherits Dynamic.DynamicObject
 End Class

This is a sample controller:
Public Class DemoController
    Inherits Controller
 
    Public Function Index() As ActionResult
        Dim list As New List(Of ModelX)
        Dim item As Object
 
        item = New ModelX
        item.PropertyA = 1
        item.PropertyB = "Something"
        list.Add(item)
 
        item = New ModelX
        item.PropertyA = 2
        item.PropertyB = "Something else"
        list.Add(item)
 
        item = New ModelX
        item.PropertyA = 3
        item.PropertyB = "Another thing"
        list.Add(item)
 
        Return View(list)
    End Function
 
End Class

And this is an extract of the view:
myGrid.Columns(Sub(header As Telerik.Web.Mvc.UI.Fluent.GridColumnFactory(Of TModelo))
    'this approach
    header.Bound("PropertyA")
    'or this another
    header.Bound(Of Integer)(ExpressionBuilder.Expression(Of TModelo, Integer)("PropertyA"))
    '...

Neither approach works as expected for me.  Is there a way to accomplish what I want?

Thanks for your help.
Tags
Grid
Asked by
Cristian
Top achievements
Rank 1
Share this question
or