Hi,
I'm wondering if it's possible to bind the ForeignKey column builder to a collection other than MVC's SelectList (for example, one with items containing properties other than just Id and Text).
In the regular DropDownListBuilder, there is an overload of BindTo() that takes an IEnumerable that allows you to do this, but from looking at the source code, all of the ForeignKey overloads for IEnumerable just convert it to a SelectList internally. My reason for wanting this is that we frequently have cases where the data in the ForeignKey needs an additional ID property for some related entity that we use for filtering the data source later.
The only way I've found to solve this so far is to use a Bound column instead and specify an editor template that uses a DropDownList with the BindTo overload that takes an IEnumerable. The problem with this is that the column will only display the integer ID outside of edit mode -- using ForeignKey will do the ID -> text mappings automatically in either mode. Is there a better way to do this?
Thanks,
Nick
I'm wondering if it's possible to bind the ForeignKey column builder to a collection other than MVC's SelectList (for example, one with items containing properties other than just Id and Text).
In the regular DropDownListBuilder, there is an overload of BindTo() that takes an IEnumerable that allows you to do this, but from looking at the source code, all of the ForeignKey overloads for IEnumerable just convert it to a SelectList internally. My reason for wanting this is that we frequently have cases where the data in the ForeignKey needs an additional ID property for some related entity that we use for filtering the data source later.
The only way I've found to solve this so far is to use a Bound column instead and specify an editor template that uses a DropDownList with the BindTo overload that takes an IEnumerable. The problem with this is that the column will only display the integer ID outside of edit mode -- using ForeignKey will do the ID -> text mappings automatically in either mode. Is there a better way to do this?
Thanks,
Nick