In Rest Results Explorer i showed how to Create a treeview from json using the treeView control. Objects like the treeview are generally dealt with recursively - see Getting started with recursion and Getting to Grips with recursion for more detail on this simple yet elusive technique. Here I will show how to traverse a treeview in just a few lines of code.
This example will use the treeview implemented in Rest Results Explorer , and select or unselect branches of data returned by a tweetsentiment query to the Rest Results Explorer. In the example, i have checked trends (and need all children to be checked), but have unchecked description, and similarily I would expect the children of description to become unchecked.
All that is required is to deal with the nodeCheck event, and pass through the state of the checked box to each of the nodes' children, which recursively call their children to pass on the status of the parents' check box. This is all there is to it.
Getting to Grips with recursion. In the meantime why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available.
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Get Started Snippets >