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

4 posts, 0 answers
  1. TJim
    TJim avatar
    9 posts
    Member since:
    May 2018

    Posted 08 Aug 2018 Link to this post

         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>

     

     

  2. TJim
    TJim avatar
    9 posts
    Member since:
    May 2018

    Posted 09 Aug 2018 in reply to TJim Link to this post

    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.

  3. TJim
    TJim avatar
    9 posts
    Member since:
    May 2018

    Posted 09 Aug 2018 in reply to TJim Link to this post

    Never mind, got the solution, can we have the option to delete/edit our posts?
  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1756 posts

    Posted 10 Aug 2018 Link to this post

    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.
Back to Top