I am attempting to get a list of items in the drop down via javascript. It appears to return a length of 0 in the collection. The dropdown has about 40 items.....
What gives?
dropDown.get_items().getLength();
Thanks,
Angel
I know this. What i am saying is it is returning 0. <%@ Register assembly="Infragistics4.Web.v10.2, Version=10.2.20102.2091, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" namespace="Infragistics.Web.UI.ListControls" tagprefix="ig"%>
.
..
function
wddRoles_Initialize(sender, eventArgs){
alert(_wddRoles.get_items().get_length())
}
It is loaded by DataSource = DataTable.
Is there something that i am missing??
hi,
what you have in your application is "get_length()", while i wrote "getLength()". These are two different functions. The first one returns the actual number of CSOM javascript objects for the items - while the second one returns the size of the dom elements in the list - this is what you are looking for. When the control has AutoFiltering=Server and Off, there is automatic "Lazy Loading", which means javascript objects for the items are not created all at once, but on demand.
Ok, All i what to do at this point is select the item in the list, client side. It runs but nothing happens??
var items = _wddRoles.get_items();
var length = items.getLength();
var item;
for (var i = 0; i < length; i++) {
item = items.getItem(i);
if (item.get_value() == txtPreviousRole.value) {
item.set_selected(
true);
items.add(item);
break;
Excellent....thanks.
Hi,
you can do item.select() to select it and have visual styles applied, and item.unselect() to remove styling and remove selected state . set_selected(true/false) only sets the internal CSOM state, that's useful if you want to select and postback, without having immediate styles applied visually.
There are actually a couple of shortcuts for client-side selection (dropdown is the control object, or "sender", as it is usually passed in client-side event handlers):
dropDown.selectItem(item);
dropDown.selectItemByIndex(itemIndex);
Hope it helps. Thanks,