2

I have a class

public class LookupClass { public int Id { get; set; } public string Name { get; set; } } 

That I have referenced in another class

public class Sampleclass { public int Id { get; set; } public LookupClass LookupEntry { get; set; } } 

which is is displayed in a KendoUI Grid

@(Html.Kendo().Grid<SampleClass>() .Name("SomeGrid") .Columns(cols => { cols.Bound(o => o.LookupEntry).Title("Lookup Column") // Displays [object Object] cols.Bound(o => o.LookupEntry.Name) // displays name correctly } .DataSource(datasource => // leaving this out since the data is seems to be loading correctly. ) ) 

When displaying the grid it just displays [object Object] for the value in the cells in the "Lookup Column" column. I have gotten the editor template working (leaving out code since not necessary, basically copied from here) and saving/loading works (left out for simplicity), but I can't seem to figure out how to display the Name property from the Lookup class.

3
  • Column binding works on a property and not on a class level, the reason you got that [object Object]. Commented Apr 24, 2013 at 6:48
  • 1
    On the Kendo UI site they have an example that uses the class level to do an editorTemplate with a dropdown, so I am assuming that there must be a way to make this display the class too. Commented Apr 24, 2013 at 7:02
  • I think there should be an editor template if you will be binding to a class, similar to if how you will do it in a view. You should probably check that. Commented Apr 24, 2013 at 7:09

1 Answer 1

3

Found a KendoUI example that shows how to do this (http://demos.kendoui.com/web/grid/editing-custom.html)

Basically you have to use a ClientTemplate to display the property you want to display

@(Html.Kendo().Grid<SampleClass>() .Name("SomeGrid") .Columns(cols => { cols.Bound(o => o.LookupEntry).ClientTemplate("#=LookupEntry.Name#").Title("Lookup Column") } ) 

On a side note, if you try to create a new record, it will produce an error about not finding LookupEntry (don't remember exact message). In the example listed, there is also a bit in the model section that shows how to set a default object.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.