1
votes

Trying to use the Multiselect kendoui widget wrapper. The server side filtering is working fine but i can't get the initial values to be populated when the widget initializes. Do you know what i'm doing wrong here?

<div class="container-div grid-tab-content-pane">

@(Html.Kendo().MultiSelect()
      .Name(AMultiName)
      .DataTextField("PrettyText")
      .DataValueField("MapAbbreviation")
      .Placeholder("Edit EMR maps...")
      .Filter(FilterType.Contains)
      .MinLength(3)
      .AutoBind(false)
      .HighlightFirst(true)
      .Value(new []
          {
              new {PrettyText = "Abcdef",MapAbbreviation = "s01"},
              new {PrettyText = "2nde obn", MapAbbreviation = "asdf012"}
          })

      .DataSource(ds => ds.Read(r=>r.Action("ReadMapOptions","EmrMappingKendo", new {Area="Messaging"})).ServerFiltering(true)).MinLength(3)   
      )

BTW i'm using version 2013.2.918.340 of the kendoui dll

Setting autobind to false has no affect.

 @(Html.Kendo().MultiSelect()
      .Name(AMultiName)
      .DataTextField("PrettyText")
      .DataValueField("MapAbbreviation")
      .Placeholder("Edit EMR maps...")
      .AutoBind(true)
      .Value(new []
          {
              new {PrettyText = "Abcdef",MapAbbreviation = "s01"},
              new {PrettyText = "2nde obn", MapAbbreviation = "asdf012"}
          })

      .DataSource(ds => ds.Read(r=>r.Action("ReadMapOptions","EmrMappingKendo", new {Area="Messaging"})).ServerFiltering(true)).MinLength(3)   
      )
3

3 Answers

2
votes

For some reason this works. Not sure why but it does.

@(Html.Kendo().MultiSelect()
      .Name(AMultiName)
      .DataTextField("PrettyText")
      .DataValueField("MapAbbreviation")
      .Placeholder("Edit EMR maps...")
      .Filter(FilterType.Contains).MinLength(3)
      .AutoBind(false)
      .DataSource(
        ds => ds.Read(r=>r.Action("ReadMapOptions","EmrMappingKendo", new {Area="Messaging"})))
      .Value(new List<EmrMapping>
          {
              new EmrMapping {PrettyText = "Abcdef",MapAbbreviation = "s01"},
              new EmrMapping {PrettyText = "2nde obn", MapAbbreviation = "asdf012"}
          })
      )

came across this link which pointed me do Kendoui docs

0
votes

.AutoBind(false) is the cause, we have to set it true to set some value(s) on initialization. Moreover, .MinLength(3) may retrict server calls, hope its deliberate.

0
votes

Yes,auto bind has nothing to do with making multi select values pre selected on page load.

To make multiselect as preselected with the datasource it got bound with,

we need to call one action method which in turn returning a list of type List items = new List();

and on UI side we need to call like this:

.Value(Model.Getsources)

here Getsources is method in controller returning list of values.