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

initial values never populated

3 Answers 142 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
chris
Top achievements
Rank 1
chris asked on 31 Oct 2013, 10:05 PM
I'm having issues getting my initial values to be populated in the multiselect widget.  The ajax request works for filtering just fine, however i can never get the initial values to populate even if i hard code them as below:

Im using v 2013.2.918.340 of Kendo.Mvc.dll
<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)
          .DataSource(ds => ds.Read(r=>r.Action("ReadMapOptions","EmrMappingKendo", new {Area="Messaging"})).ServerFiltering(true))
          .Value(new List<EmrMapping>()
              {
                  new EmrMapping(){PrettyText = "Abcdef",MapAbbreviation = "s01"},
                  new EmrMapping(){PrettyText = "2nde obn", MapAbbreviation = "asdf012"}
              })        
          )

</div>
What am i doing wrong?

Edit:

I even tried hardcoding the value as a dynamic type like the example shows but I get the same result.  No js errors on the page and the widget appears to work except the initial values aren't displayed..

<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)  
          )
 
</div>

3 Answers, 1 is accepted

Sort by
0
chris
Top achievements
Rank 1
answered on 01 Nov 2013, 03:57 PM
I've tried to simplify the widget down to this:
@(Html.Kendo().MultiSelect()
         .Name(AMultiName)
         .DataTextField("PrettyText")
         .DataValueField("MapAbbreviation")
         .Placeholder("Edit EMR maps...")
         .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)  
         )
But i get the same thing, no initial values set.  So i think I'm going to have to try a hack like setting the multiselect's values on document.ready from the result of an ajax request..
0
chris
Top achievements
Rank 1
answered on 01 Nov 2013, 04:11 PM
ok this seems to work.

@(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"}
              })
          )
Not sure where i found to set the serverfiltering on the datasource read attribute but seems that removing that might have fixed it.
0
Daniel
Telerik team
answered on 04 Nov 2013, 12:11 PM
Hello Chris,

What code are you using to filter the data on the server? The initial items will not be set if the data returned from the server does not contain items with the same values.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MultiSelect
Asked by
chris
Top achievements
Rank 1
Answers by
chris
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or