Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Add Multiple Item in Radcombobox using jquery

5.00/5 (1 vote)
24 Dec 2014CPOL 12.9K  
Add multiple items in Radcombobox using jquery

Introduction

To bind Telerik RadComboBox in Telerik Website, give only one item. But, here, I am adding multiple items in RadComboBox Using Jquery.

First, I am binding Rccolname at server side and OnClientDropDownClosed I am binding other RadCombobox.

So, first, I create a function rccolname on this get index of Rccolname combo and set this is as rccoltype Combo.

After that, on this get selected value, I have switch case condition in every case I inserted value in the array. After that, I have inserted Item in Rcombooperator using For loop.


JavaScript
function rccolnameChange(sender, args) {
        var item = args._domEvent.target.innerText
        var index = sender._selectedIndex;
        var rccoltyp = $find("<%= rcColType.ClientID %>");
        rccoltyp._selectedIndex = index; //set index of RcColtype Conmbo
        var rccol = $find("<%= rcColType.ClientID %>");
        var name = rccol._childListElement.childNodes[index].innerText;// Get Selected Index Text

          if (index != 0) {
              var selectitem = new Array();
               switch (name.toLowerCase()) {
                   case 'datetime': case 'system.datetime':
                       selectitem.push("=");
                       selectitem.push(">");
                       selectitem.push("<");
                       selectitem.push("<=");
                       selectitem.push(">=");
                       selectitem.push("<>");
                       selectitem.push("IS NULL");
                       selectitem.push("IS NOT NULL");
                       selectitem.push("BETWEEN");
                       break;
                   case 'numeric': case 'decimal':
                       selectitem.push("=");
                       selectitem.push(">");
                       selectitem.push("<");
                       selectitem.push("<=");
                       selectitem.push(">=");
                       selectitem.push("<>");
                       selectitem.push("IS NULL");
                       selectitem.push("IS NOT NULL");
                       selectitem.push("Browse");
                       break;
                   case 'varchar': case 'string': case 'system.string': case 'char':
                       selectitem.push("=");
                       selectitem.push("<>");
                       selectitem.push("IS NULL");
                       selectitem.push("IS NOT NULL");
                       selectitem.push("End With");
                       selectitem.push("contains");
                       selectitem.push("Browse");
                       break;
               }

               var combo = $find("<%= RComboOperator.ClientID %>");
               combo.clearItems();
               var length = selectitem.length
               for (i = 0; i < selectitem.length; i++) {
                   var comboItem = new Telerik.Web.UI.RadComboBoxItem();

                   comboItem.set_text(selectitem[i]);
                   combo.trackChanges();
                   combo.get_items().add(comboItem);
                   combo.commitChanges();
                   comboItem.select();
               }
           }
       }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)