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

[Solved] Inserting a Telerik ComboBox into an Telerik ASP.Net MVC3 Grid

0 Answers 147 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Douglas
Top achievements
Rank 1
Douglas asked on 27 Apr 2012, 02:54 PM

I have an ASP.NET MVC3 View that has a Telerik Grid that uses a viewmodel for its data.

One of the requirements is that we need a dropdown control in one of the grid columns which gets data from a lookup table.

Being relatively new to MVC3, I figured that since the Razor View can only use one model directive IE:

@model IEnumerable<MarketingWebsiteTools.Models.EditableItemInfo>

that the dropdown lookup valueswould need to be mapped back to the ViewModel along with the data for the grid.

At this point it might be pertinent to mention that I'm using Html.Telerik().ComboBox() in a ClientTemplate like this:

.Columns(columns =>
{
columns
.Bound(o => o.ItemNmbr).Width(65);//.ClientTemplate("<label name='ProductIdentifier' />");
columns
.Bound(o => o.Description).Width(65)
.ClientTemplate(Html.Telerik().ComboBox()
.Name("Special")
**.BindTo(new SelectList())**
.ToHtmlString());
columns
.Bound(o => o.Start_Date).Width(75).Format("{0:d}");
columns
.Bound(o => o.End_Date).Width(75).Format("{0:d}");
columns
.Bound(o => o.PromotionText).Width(75);
columns
.Command(commands => commands.Delete()).Width(125).Title("Delete");
})

My question is: In respect to the BindTo(new SelectList()), I need to provide a parameter of type System.Collections.Generic.IEnumerable, however I'm unsure how to get that from my viewmodel, or perhaps, I should be getting that lookup data another way...

I looked at this example:
http://www.telerik.com/community/forums/aspnet-mvc/combobox/bindto.aspx

However, My code or intellisense doesn't seem to be recognizing any models IE:
.BindTo(new SelectList(Model.))

I also looked at this example:
http://stackoverflow.com/questions/3752182/how-to-insert-dropdown-list-box-in-telerik-grid

where it looks like there's a call to a method in a controller, but again, no access to that controller..

thanks in advance for any help.

doug

Tags
ComboBox
Asked by
Douglas
Top achievements
Rank 1
Share this question
or