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
495
Searching the WebDataTree via the client api
posted

Hi,

I'm currently implementing some client-side functionality to search a WebDataTree, and was hoping to clarify a few details about the tree csom.

The server-side api provides an "AllNodes" property which contains an array of every node already in depth-first order.  Is there a similar mechanism provided via the csom?  Or would I need to implement my own depth-first search algorithm in this case?  This would also be useful if I had a way to uniquely identify a specific node (for example, index in AllNodes array), for easier retrieval later on.  If I'm only able to store the node value or relative index, it seems as though I'd need to search through the tree each time I wanted to re-retrieve it.  

Thanks,

Rob Quick

 

 

Parents
  • 14517
    Verified Answer
    Offline posted

    Hi Rob,

    You are correct the client side object model works differently than the server-side api. Your best option to implement similiar functionality on the client is to implement a depth-first search.

    The tree provides a method, resolveItem, which can be used to directly find a node. This method is passed an address which specifies the node. The address of a particular node can be obtained using the _get_address() function of the node.

    The attached sample implements a client side traversal of the tree and also uses the resolveItem method to find an element in the tree.

    Please let me know if you have any other questions.
    Valerie

    NodeSearch.zip
Reply Children