This is a migrated thread and some comments may be shown as answers.
Multiselect serverfiltering true not retaining values when returing from controller
3 Answers 64 Views
This is a migrated thread and some comments may be shown as answers.
Mohanapriya
Top achievements
Rank 1
Mohanapriya asked on 14 Aug 2017, 05:10 PM

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.

 

 

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 16 Aug 2017, 11:52 AM
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.
0
ShareDocs
Top achievements
Rank 1
answered on 13 Nov 2017, 09:11 AM

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"])

)

       

0
Nencho
Telerik team
answered on 15 Nov 2017, 07:53 AM
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.
Asked by
Mohanapriya
Top achievements
Rank 1
Answers by
Nencho
Telerik team
ShareDocs
Top achievements
Rank 1
Share this question
or