Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
binding a column to child property
posted

Using version 2011.2 trying to bind to a property of a child object using the MVC helper...

..
.Columns(x => {
 x.For(y => y.Script.Name).Width("auto").HeaderText("Script Name");
...
})

Fails because the key is set to just "Name" which doesn't exist on y. I tried forcing the Key to "Script.Name", but that didn't help.

Do I have to make a flat view model?

  • 3115
    Offline posted

    Hi wpbrown,

    What are you trying to acheive with y.Script.Name?

    What is expected in tha lambda expression is the key correcponding to your model.  So if that's your child layout and you have set correclty Primary Key and Foreign Key properties, this ScriptName property should be part of your model.

    Can you send us your sample, to provide you more correct information which will help you?

    Thanks,

  • 7566
    posted

    Hello Wpbrown,

     

    If you have the following declaration

     

    public class MyClass

    {

                   

                    public Code Script {set; get;}

                   

    }

     

    public class Code

    {

                   

                    public string Name {set; get;}

    }

     

    You need to pass to the view

    @model IQueryable<MyClass>

     

    There in the column declarations you need

    .Columns(column =>

    column.For(x => x.Script.Name).HeaderText("Name");

     

    I hope this helps.

     

     

    Sincerely,

    Georgi Sashev

    Developer Support Engineer

    Infragistics, Inc.

    http://es.infragistics.com/support