Click here to Skip to main content
15,891,033 members
Articles / Web Development / ASP.NET
Tip/Trick

Add Multiple Item in Radcombobox using jquery

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
24 Dec 2014CPOL 12.4K   3
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)


Written By
Software Developer (Senior) Skyz Infotech
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionSound interesting Pin
vghost25-Dec-14 12:13
vghost25-Dec-14 12:13 
AnswerRe: Sound interesting Pin
Tushar sangani26-Dec-14 16:49
professionalTushar sangani26-Dec-14 16:49 
GeneralRe: Sound interesting Pin
vghost4-Feb-15 4:18
vghost4-Feb-15 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.