Multiselect serverfiltering true not retaining values when returing from controller

4 posts, 0 answers
  1. Mohanapriya
    Mohanapriya avatar
    1 posts
    Member since:
    Jan 2015

    Posted 14 Aug Link to this post

    I have a multiselect with serverfiltering set to true. It works fine to filter. Now, when I post the control to my controller, I get the ids and that is fine too. But, when I return to my view with the same set of ids, the multiselect textbox is empty. The ids come back, but there is no select option to show the values. How can I retain the values in multiselect texbox when serverfiltering true and returning to the same view.

     

     

  2. Nencho
    Admin
    Nencho avatar
    1671 posts

    Posted 16 Aug Link to this post

    Hello Mohanapriya,

    I am afraid that we would need a bit more information about your scenario. Could you demonstrate how exactly you return to the view and how the data is passed back. In addition, please demonstrated the implementation for the multiselect in the view.

    Regards,
    Nencho
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. ShareDocs
    ShareDocs avatar
    88 posts
    Member since:
    Oct 2012

    Posted 13 Nov Link to this post

    Hi, 

    I have a similar problem.

         @(Html.Kendo().MultiSelectFor(
              model => model.Filters.Property1)
                              .Filter(FilterType.Contains)
                              .TagMode(TagMode.Single)
                              .TagTemplateId("MultiSelectTemplate")
                              .AutoBind(false)
                              .DataSource(source => source.ServerFiltering(true)
                              .Read(read => { read.Action("GetPropByStr", "SomeController"); }))
                              .DataTextField("Name")
                              .DataValueField("Value")
                              .Value((List<MyItemList>)TempData["SelectedValues"])
      )

     

    TempData["SelectedValues"]  contains the list of selected items.

    When the form is submitted, the selected values are postted to my controller.

    After return view,  the multiselect.values() contains the selected values but the dataitems is null so no item can being selected.

    I notice, that if I put multiselect that its values are not post to the controller, it work perfect.

    Like this

       @(Html.Kendo().MultiSelect(
                              .Name("MyMultiSelect")
                              .Filter(FilterType.Contains)
                              .TagMode(TagMode.Single)
                              .TagTemplateId("MultiSelectTemplate")
                              .AutoBind(false)
                              .DataSource(source => source.ServerFiltering(true)
                              .Read(read => { read.Action("GetPropByStr", "SomeController"); }))
                              .DataTextField("Name")
                              .DataValueField("Value")
                              .Value((List<MyItemList>)TempData["SelectedValues"])

    )

           

  4. Nencho
    Admin
    Nencho avatar
    1671 posts

    Posted 15 Nov Link to this post

    Hello,

    I would suggest you a slightly different implementation - since you use the MultiSelectFor, you don't need to set the values, because the idea of the MultiSelectFor is to bind to certain data and set as selected the values which where defined in the model and passed trough a tempData (ViewBag or ViewData applicable as well).

    Please refer to this Code Library, where this implementation is demonstrated:

    https://www.telerik.com/support/code-library/post-multiselect-with-a-form-element

    In addition, this topic is discussed in the following forum thread:

    https://www.telerik.com/forums/multiselect-and-form-not-sending-values-back

    Regards,
    Nencho
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top