How to use Lookup with a complex viewmodel

Dec 9, 2010 at 10:16 PM

It looks like the default helpers:  EditorFor, LookupFor, Lookup  wont work if your view uses a complex model.

This wont work: 

Html.EditorFor(model=>model.TeamMember.PersonID)

This kinda works:  

Html.Lookup("PersonID",Model.TeamMember.PersonID,controller:"PersonIDLookup")

But, it generates the form field: PersonID instead of TeamMember.PersonID

Also tried this but no luck: 

Html.Lookup("TeamMember.PersonID",Model.TeamMember.PersonID,controller:"PersonIDLookup")

Any ideas?

Coordinator
Dec 10, 2010 at 6:49 AM

Hi,

Thnx for contributing

I did this today, you can either wait until the next release or

replace you Awesome folder with the one from the current source code

 

Dec 10, 2010 at 1:58 PM
Edited Dec 10, 2010 at 2:52 PM

Fantastic - that worked great!

You have to use:

Html.Lookup("TeamMember.PersonID", Model.TeamMember.PersonID, controller:"PersonIDLookup") 

FYI:

EditorFor(model=>model.TeamMember.PersonID) - didnt do anything, maybe I needed to create a template?

Html.LookupFor(model => model.TeamMember.PersonID,controller:"PersonIDLookup") - showed the button, but didnt show the person on the edit screen.

 

Thanks for creating a great project of awesome features!

Coordinator
Dec 11, 2010 at 9:56 AM

in the demo from the source code in index.aspx for LookupDemoController I do:

    <%=Html.EditorFor(o => o.Team.ThePerson) %>

and it works, try running the demo