Hi,
I am using a RadComboBox with an embedded RadTreeview. It is coded pretty much exactly as the samples were.
However I have AutoPostBack=True on the RadComboBox so I can catch the SelectedIndexChanged event on the server.
The only problem seems to be that the SelectedIndexChanged event does not happen until the RadCombo loses focus. I would like it to happen when the user selects an item in the treeview.
Below is the client side code I have attached to the combo.
Any help would be great.
Thanks ... Ed
I am using a RadComboBox with an embedded RadTreeview. It is coded pretty much exactly as the samples were.
However I have AutoPostBack=True on the RadComboBox so I can catch the SelectedIndexChanged event on the server.
The only problem seems to be that the SelectedIndexChanged event does not happen until the RadCombo loses focus. I would like it to happen when the user selects an item in the treeview.
Below is the client side code I have attached to the combo.
Any help would be great.
Thanks ... Ed
function tvCombo_Load(sender, eventArgs) |
{ |
sender.set_text(sender.get_items().getItem(0).get_value()); |
} |
function tvCombo_NodeClicking(sender, args) |
{ |
var node = args.get_node(); |
var tv = node.get_treeView(); |
var bLeavesOnly = tv.get_attributes().getAttribute("LeavesOnly"); |
var cboId = tv.get_attributes().getAttribute("cboId"); |
if (bLeavesOnly == "true") // they can only select leaves |
{ |
// add in the following code as a condition to disable root nodes that are leaves from being selected |
// || node.get_parent().get_parent() == null |
if (node.get_nodes().get_count() > 0) |
{ |
args.set_cancel(true); |
return; |
} |
} |
var ddl = $find(cboId); |
ddl.trackChanges(); |
ddl.set_text(node.get_text()); |
ddl.get_items().getItem(0).set_value(node.get_text()); |
ddl.commitChanges(); |
ddl.hideDropDown(); |
} |
function tvCombo_StopPropagation(e) |
{ |
if (!e) |
e = window.event; |
e.cancelBubble = true; |
} |
function tvCombo_OnClientDropDownOpenedHandler(sender, eventArgs) |
{ |
var cboItem = sender.get_items().getItem(0); |
var treeId = sender.get_attributes().getAttribute("tvId"); //cboItem.get_attributes().getAttribute("TreeId"); |
if (treeId) |
{ |
var tv = cboItem.findControl(treeId); |
var selectedNode = tv.get_selectedNode(); |
if (selectedNode) |
{ |
// expand the parents |
var oNode = selectedNode.get_parent(); |
while (oNode) |
{ |
// can't expand the root's parent as it is the treeview itself |
if(oNode.get_parent()) |
oNode.expand(); |
oNodeoNode = oNode.get_parent(); |
} |
selectedNode.scrollIntoView(); |
} |
} |
} |