When a json result is returned by the controller the object name seems to be missing, I normally wouldn't mind but the flexbox jquery plugin requires the json result in a particular format.
Flexcombobox expected format
{"results":[
{"id":"1","name":"Ant"},
{"id":"2","name":"Bear"},
{"id":"3","name":"Cat"},
{"id":"4","name":"Dog"},
{"id":"5","name":"Elephant"},
{"id":"6","name":"Fox"},
{"id":"7","name":"Guinea Pig"},
{"id":"8","name":"Horse"},
{"id":"9","name":"Iguana"},
{"id":"10","name":"Jaguar"}
]}
Class
Public Class FlexboxResult
Private _id As String
Public Property Id() As String
Get
Return _id
End Get
Set(ByVal value As String)
_id = value
End Set
End Property
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
End Class
Controller Code
Function PartYearsList() As JsonResult
Dim yearSelectList As List(Of FlexboxResult) = New List(Of FlexboxResult)
For index As Integer = DateTime.Now.Year To 1955 Step -1
yearSelectList.Add(New FlexboxResult() With {.Id = index, .Name = index})
Next
Return Me.Json(yearSelectList.ToArray(), JsonRequestBehavior.AllowGet)
End Function
Json result returned (shortened)
[{"Id":"2010","Name":"2010"},{"Id":"2009","Name":"2009"},{"Id":"2008","Name":"2008"}]
Desired result (shortened)
{"results": [{"Id":"2010","Name":"2010"},{"Id":"2009","Name":"2009"},{"Id":"2008","Name":"2008"}]}
Flexcombobox documentation http://www.fairwaytech.com/flexbox.aspx