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

Keep getting UNDEFINED in my selectlist when bound!

1 Answer 96 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ryan Lege
Top achievements
Rank 1
Ryan Lege asked on 06 Aug 2012, 08:59 AM
I have tried everything! I am doing a load on demand scenario. Every time it loads the results, every selection says UNDEFINED. Here is the code:


//HERE IS THE MODEL

    public class TscmisModel
    {
        public SelectList LoadOnDemandList { get; set; }
    }

//THIS IS A PARTIAL
@model USARAFSyncMVC.Areas.Event.Models.TscmisModel

@(Html.Kendo()
      .ComboBox()
      .HtmlAttributes(new { style = "width: 900px" })
      .Name("cbTscmis")
      .Filter(FilterType.StartsWith)
      .MinLength(3)
      .Suggest(true)
      .DataTextField("Text")
      .DataValueField("Value")
      .HighlightFirst(true)
      .BindTo(Model.LoadOnDemandList)
      .DataSource(source =>
      {
          source.Read(read =>
          {
              read.Action("_LoadTscmisData", "Event", new { area = "Event" });
          }).ServerFiltering(true);
      }))




//THIS IS THE SERVER METHOD
        public ActionResult _LoadTscmisData(string text)
        {
            TscmisModel model = new TscmisModel();
            if (!string.IsNullOrEmpty(text))
            {
                model.LoadOnDemandList = miscRepository.LoadTscmisData(text);
                return PartialView("TscmisPartial", model);
            }
            model.LoadOnDemandList = new SelectList(new List<SelectListItem>());
            return PartialView("TscmisPartial", model);
        }

1 Answer, 1 is accepted

Sort by
0
Ryan Lege
Top achievements
Rank 1
answered on 08 Aug 2012, 07:04 AM
Solved!!! Needed to return a JSON object collection not a ActionResult
Tags
ComboBox
Asked by
Ryan Lege
Top achievements
Rank 1
Answers by
Ryan Lege
Top achievements
Rank 1
Share this question
or