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

MultiSelect - If any value is selected, then execute custom function, if none, also execute custom function

3 Answers 350 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
TJim
Top achievements
Rank 1
TJim asked on 08 Aug 2018, 07:02 PM

     I'm looking to show/hide the "require input" asterisk (*) once a value is not selected/selected. Is there a way to do this with MultiSelect? I see that there are onSelectAll & onDeselectAll but there's no function that handles onSelect of any value -- how would I handle this with MultiSelect?

 

My current markup:

<div id="@(Model.Name + "InitialLoading")" class="CheckboxListInitializing"><img style="height: 13px;margin-right: 5px;" src="../Content/images/loading.gif">Loading...</div>
                     <span id="@(Model.Name + "Loading")" style="display:none;position: absolute;">
                         <img src='../Content/kendo/2016.1.406/Bootstrap/loading.gif' />
                     </span>
                     <script>
                     $(function ()
                     {
                         $("#@(Model.Name)").multiselect({
                             includeSelectAllOption: true
                             //, selectAllValue: "[All]"
                             , selectAllText: "(Select All)"
                             , enableFiltering: true
                             , enableCaseInsensitiveFiltering: true
                             , onDropdownShown: function (event) {
                                 this.$select.parent().find("button.multiselect-clear-filter").click();
                                 this.$select.parent().find("input[type='text'].multiselect-search").focus();
                                 $(".@(Model.ItemName)").hide();
                             }
                             , nonSelectedText: "  "
                             , onInitialized: function () { $("#@(Model.Name)InitialLoading").hide(); $(".@(Model.ItemName)").hide(); }
                             , onChange: function () { ListChangeHandler( $("select[id=@Model.Name]"));}
                             , onSelectAll: function () { ListChangeHandler( $("select[id=@Model.Name]"));  $(".@(Model.ItemName)").hide();}
                             , onDeselectAll: function () { ClearWholeList($("select[id=@Model.Name]")); ListChangeHandler($("select[id=@Model.Name]")); $(".@(Model.ItemName)").show(); }
                             @*@(!string.IsNullOrEmpty(Model.ChangeHandler) ? ", onChange: " + Model.ChangeHandler + ", onSelectAll: " + Model.ChangeHandler + ", onDeselectAll: " + Model.ChangeHandler : "")*@
                         });
 
                         LoadListBox("@(!string.IsNullOrEmpty(Model.CascadedFromName) ? Model.Name : "")");
 
                     })
                     </script>

 

 

3 Answers, 1 is accepted

Sort by
0
TJim
Top achievements
Rank 1
answered on 09 Aug 2018, 11:56 PM

Hi I still need the solution for this. I would like to call a function when there's 1 or more selection has been made,  and when there's no selection, it will also fire a function (without clicking onDeselectAll).

 

Please provide code examples for this since it requires custom coding.

0
TJim
Top achievements
Rank 1
answered on 10 Aug 2018, 12:38 AM
Never mind, got the solution, can we have the option to delete/edit our posts?
0
Ivan Danchev
Telerik team
answered on 10 Aug 2018, 09:35 AM
Hello,

Currently post editing and deletion is not available in the forums.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
MultiSelect
Asked by
TJim
Top achievements
Rank 1
Answers by
TJim
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or