This is a migrated thread and some comments may be shown as answers.

Iterate through rows in multicolumn radcombobox

2 Answers 216 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Neema Sridhar
Top achievements
Rank 1
Neema Sridhar asked on 14 Jul 2010, 06:49 AM
Hi,

I need to loop through every row in a multicolumn dropdown in client side, how can this be acheived?

Scenario. There is a multicolumn radcombobox whith 3 columns, User enter a value in a textbox which should get added to the multicolumn racombo. Before inserting the value to the combo I need to check if that value which user has entered is already present in the list or not. If the value is there in the list already I need to display a error message to the user. I need this to be acheived client side. I need to loop through every row in the item list and get the value of the first column.

Please let me know how can  this be accomplished.

2 Answers, 1 is accepted

Sort by
0
Neema Sridhar
Top achievements
Rank 1
answered on 14 Jul 2010, 07:25 AM
Hi,

I just implemented the below logic and it worked. Please review this and let me know if this solution is okay, I checked in IE and Firefox and it worked fine.

 

 

 

function ValidateForDuplicate()
  
{
  
var combo = $find('<%= RadComboBox1.ClientID %>');
  
var newAccNum = document.getElementById('accNumber').value;
  
for (var i = 0; i < combo.get_items()._array.length; i++) 
  
  
var ctrl = combo.get_items().getItem(i);
  
if(ctrl != null ) 
  
{
  
  
var b = ctrl.get_attributes().getAttribute("DebitAccountNumber");
  
alert(b);
  
}
  
}
  
return false;
  
}

I am setting the attributes in the ItemDataBound event.

0
Yana
Telerik team
answered on 14 Jul 2010, 10:05 AM
Hello Neema,

The javascript function seems ok, you can only change this  - "combo.get_items()._array.length"  to "combo.get_items().get_count()".

Regards,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Neema Sridhar
Top achievements
Rank 1
Answers by
Neema Sridhar
Top achievements
Rank 1
Yana
Telerik team
Share this question
or