initial values never populated

4 posts, 0 answers
  1. chris
    chris avatar
    19 posts
    Member since:
    Jan 2013

    Posted 31 Oct 2013 Link to this post

    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>

  2. chris
    chris avatar
    19 posts
    Member since:
    Jan 2013

    Posted 01 Nov 2013 Link to this post

    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..
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. chris
    chris avatar
    19 posts
    Member since:
    Jan 2013

    Posted 01 Nov 2013 Link to this post

    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.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 04 Nov 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready