Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
WebData Tree: Unable to Read selected values when using Master Pages
posted

I am using infragistics webdatatree in the aspx page.

I need to validate the tree by checking whether the user has selected at least one of the tree nodes or not, the code to do it is,

 

var tree = $find("<%= igTreeSalesOrg.ClientID %>");

 

if (tree.get_checkedNodes().length == 0) {

     document.getElementById("liNoSearchCriteria").style.display = "block";

     validated = false;

}

 

The webdatatree id is igTreeSalesOrg.

 

The above code works fine for the simple aspx page, but when I place the tree control in a content panel (using master page) and place the validation

Script in the separate file the tree is not being recognized by the script.

 

 

  • 37874
    posted

    Hello amalinchatterjee,

    It has been some time since your post but in case that you still need assistance I will be happy to help.

    Here is a sample solution for this issue. In the javascript file, handle the WebDataTree’s initialize event. Assign ‘sender’ argument to a global variable ‘tree’. Then you can use the function ‘validate’ according to your needs. This is the content of the javascript file:

    var tree;

     

    function initializeTree(sender, args) {

        tree = sender;

    }

     

    function validate() {

        if (tree.get_checkedNodes().length == 0) {

            var validated = false;

        }

    }

     

    Then you should add the script to your master page’s head section:

    <script type="text/javascript" src="Scripts/JScript.js"></script>

     

    You might want to consider referring the script from your content page, rather than the master page. By doing so, the javascript file will only be sent to the client when the content page containing WebDataTree is requested.

     

    Please let me know if you have any further questions.