Articles in this section
Category / Section

How to enable the user to limit the selection of items in the DropDownList

1 min read

Solution

The selection of particular item in the DropDownList can be restricted by using the client side event name called “select”.

 

Initialize the DropDownList as follows

Javascript

<input type="text" id="selectmailtools" />

 

        <div id="mailtoolslist">

             <ul>

                  <li><div class="mailtools categorize"></div>Categorize and Move</li>

                  <li><div class="mailtools done"></div>Done</li>

                  <li><div class="mailtools flag"></div>Flag & Move</li>

                  <li><div class="mailtools forward"></div>Forward</li>

                  <li><div class="mailtools movetofolder"></div>Move to Folder</li>

                  <li><div class="mailtools newmail"></div>New E-mail</li>

                  <li><div class="mailtools meeting"></div>New Meeting</li>

                  <li><div class="mailtools reply"></div>Reply & Delete</li>

             </ul>

         </div>

 

 

When selecting the items in the DropDownList, the select event will be triggered, in that check whether the corresponding item is selected or not.

 

If the particular element is selected, then set the value of the DropDownList as “null”, so that the item cannot be selected as well as if you had set a water mark in the DropDownList, that water mark will be shown.

Javascript

<script type="text/javascript">

var target;

$(function () {

    $('#selectmailtools').ejDropDownList({

        targetID: "mailtoolslist",

        watermarkText: "Select a icon",

        width: "100%",

        select : "onChange"

    });

});

function onChange(args){

      

if(args.text=="Done")

{

 

    this.setModel({value : "null"});

    args.cancel = true;

 

    }

}

</script>

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied