Hi everybody,
So, I'm running into an issues with the list box that is confusing me. I'm working on a page with a two list boxes that I'm using to transfer items back and fourth, really similar to the demo.
However, when I try to catch the OnClientTransferring event in my javascript, I'm getting a null from get_selectedItem, even though the item is selected? I tested this by adding a handler for OnClientSelectedIndexChanged, and that seems to work fine. What did I miss?
If it matter's the list boxes are populated programatically based on the input from a 3rd list box.
Here is my ListBox aspx code.
<
telerik:RadListBox
runat
=
"server"
ID
=
"RadListBoxAccountSource"
Height
=
"300px"
Width
=
"300px"
AllowTransfer
=
"true"
TransferToID
=
"RadListBoxAccountDestination"
ButtonSettings-AreaWidth
=
"35px"
>
</
telerik:RadListBox
>
<
telerik:RadListBox
runat
=
"server"
ID
=
"RadListBoxAccountDestination"
Height
=
"300px"
Width
=
"250px"
>
</
telerik:RadListBox
>
My JavaScript:
var
listBox;
function
pageLoad() {
listBox = $find(
"<%= RadListBoxAccountSource.ClientID %>"
);
}
function
SourceSelectedIndexChange() {
//This works just fine.
var
selectedItem = listBox.get_selectedItem();
alert(
"selected"
+ selectedItem.get_value());
}
function
transferRight() {
//This returns a list of the items, so I know the list box is populated.
var
Items = listBox.get_items();
//This comes back null
var
selectedItem = listBox.get_selectedItem();
if
(selectedItem ==
null
) {
alert(
"You need to select a item first."
);
return
false
;
}
else
{
listBox.transferToDestination(selectedItem);
return
false
;
}
}
Any help or advice would be welcome, I'm not sure what's going on. :/