passing parameters in OnClientNodeChecked event

2 posts, 1 answers
  1. pankaj
    pankaj avatar
    12 posts
    Member since:
    Oct 2008

    Posted 07 Oct 2008 Link to this post

    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

  2. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 Oct 2008 Link to this post

    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.
Back to Top