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

passing parameters in OnClientNodeChecked event

1 Answer 78 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
pankaj
Top achievements
Rank 1
pankaj asked on 07 Oct 2008, 11:25 AM

Hi,
I am using a treeview in combobox. I am calling a javascript function on OnClientNodeChecked event.

 

rdTreeView.OnClientNodeChecked =

"nodeChecked";
This is working fine as long as I am not passing any parameter in the function. 

 

function nodeChecked()

{

var tree = $find('RadComboBox1_i0_RadTreeView1');

var comboBox = $find('RadComboBox1');

var nodes = tree.get_checkedNodes();

 

var strText = 'you have selected ' + nodes.length + ' nodes';

comboBox.set_text(strText);

 

}

 

 

If I pass the value of combobox and treeview as parameter in function, it is being called on OnInit event and this is throwing javascript error.

As we are adding all controls at runtime and we are not sure how many controls will be added, we need to pass the Combobox and treeview as parameter.

What is the way of passing these parameters in this function?

Thanks,
Pankaj

1 Answer, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 07 Oct 2008, 02:12 PM
Hi pankaj,

OnClientNodeChecked event handler accepts two parameters:
  1. The treeview instance that fired the event.
  2. Event arguments with functions:
    • get_node() retrieves a reference to the clicked on node. 
    • get_domEvent() retrieves a DOM event object of the node check.
More information is avalable here.

Having the id of the treeview (e.g. 'RadComboBox1_i0_RadTreeView1') you can easily get the id of the containing combobox (e.g. RadComboBox1)

I hope this helps.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
pankaj
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or