Posted 17 Jan 2013
Link to this post
I have this working great now. See below for details.
I'll put my "p.s." at the top here:
p.s. Kendo UI is nothing short of AWESOME.
The view contains the following: (pretty well copied from your online documentation).
@(Html.Kendo().DropDownList()
.Name("seriesDropDownList")
.DataTextField("SERIES_NAME")
.DataValueField("SERIES_GUID")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetSeriesTest", "Series");
})
.ServerFiltering(true);
})
.Template("${ SERIES_NAME }<br/><img src='${SERIES_LOGO_IMAGE}' />")
.Height(820)
.HtmlAttributes( new { style = "width:400px;" } )
.SelectedIndex(0)
)
This is the controller part:
[AcceptVerbs(HttpVerbs.Get)]
public JsonResult GetSeriesTest() {
// using EF 4.x - Database First. The model only has 1 table in it.
SeriesEntities dbSeries = new SeriesEntities();
return Json( new { data = dbSeries.Series.ToList<Serie>() },JsonRequestBehavior.AllowGet );
}
JSON (from Fiddler) below:
[{"SERIES_GUID":"69b1fa51-3e8a-4102-4e69-39beffab17fb","SERIES_ID":"SPRINT","SERIES_NAME":"Sprint Cup Series","SERIES_ACTIVE":true,"SERIES_LOGO_IMAGE":"/Images/series/nascar-sprint-series-logo.png","SERIES_WEBSITE":"http://www.nascar.com/series/cup/","EntityState":2,"EntityKey":{"EntitySetName":"Series","EntityContainerName":"SeriesEntities","EntityKeyValues":[{"Key":"SERIES_GUID","Value":"69b1fa51-3e8a-4102-4e69-39beffab17fb"}],"IsTemporary":false}},{"SERIES_GUID":"52a3cc91-4dd9-70ec-8bd4-39beffabed58","SERIES_ID":"NATIONWIDE","SERIES_NAME":"Nationwide","SERIES_ACTIVE":true,"SERIES_LOGO_IMAGE":"/Images/series/nascar-nationwide-series-logo.png","SERIES_WEBSITE":"http://www.nationwide.nascar.com/nationwide-series/","EntityState":2,"EntityKey":{"EntitySetName":"Series","EntityContainerName":"SeriesEntities","EntityKeyValues":[{"Key":"SERIES_GUID","Value":"52a3cc91-4dd9-70ec-8bd4-39beffabed58"}],"IsTemporary":false}},{"SERIES_GUID":"6f36a620-0a45-53d8-6604-39beffac2e39","SERIES_ID":"ARCA","SERIES_NAME":"ARCA","SERIES_ACTIVE":true,"SERIES_LOGO_IMAGE":"/Images/series/nascar-arca-series-logo.png","SERIES_WEBSITE":"http://www.arcaracing.com/","EntityState":2,"EntityKey":{"EntitySetName":"Series","EntityContainerName":"SeriesEntities","EntityKeyValues":[{"Key":"SERIES_GUID","Value":"6f36a620-0a45-53d8-6604-39beffac2e39"}],"IsTemporary":false}},{"SERIES_GUID":"a8a5f909-3358-0ceb-3f99-39beffac752d","SERIES_ID":"TRUCK","SERIES_NAME":"Camping World Truck Series","SERIES_ACTIVE":true,"SERIES_LOGO_IMAGE":"/Images/series/nascar-truck-series-logo.png","SERIES_WEBSITE":"http://www.nascar.com/series/truck/","EntityState":2,"EntityKey":{"EntitySetName":"Series","EntityContainerName":"SeriesEntities","EntityKeyValues":[{"Key":"SERIES_GUID","Value":"a8a5f909-3358-0ceb-3f99-39beffac752d"}],"IsTemporary":false}},{"SERIES_GUID":"eb41cc8e-5df1-61f9-7674-39bf08e084a9","SERIES_ID":"CANADIANTIRE","SERIES_NAME":"Canadian Tire Series","SERIES_ACTIVE":true,"SERIES_LOGO_IMAGE":"/Images/series/nascar-canadian-tire-series-logo.png","SERIES_WEBSITE":"http://www.nascarlocalracing.com/series/canadian_tire_series","EntityState":2,"EntityKey":{"EntitySetName":"Series","EntityContainerName":"SeriesEntities","EntityKeyValues":[{"Key":"SERIES_GUID","Value":"eb41cc8e-5df1-61f9-7674-39bf08e084a9"}],"IsTemporary":false}}]