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.
function rccolnameChange(sender, args) {
var item = args._domEvent.target.innerText
var index = sender._selectedIndex;
var rccoltyp = $find("<%= rcColType.ClientID %>");
rccoltyp._selectedIndex = index;
var rccol = $find("<%= rcColType.ClientID %>");
var name = rccol._childListElement.childNodes[index].innerText;
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();
}
}
}