WebObjectTree Studio
Select Server:
  Reset Ready
Built-in Ajax:
This sample demonstrates how you can use the built-in Ajax ability of WebObjectTree to populate the children items.

To use this feature, you can set the following WebObjectTree property to the URL of a web service that can supply the necessary information:

WebObjectTree1.DataRetrievalUrl = "http://www.coalesys.net/WebObjectTree/Services/DemoService.asmx/GetTreeData";

This sample uses an ASP.NET Web Service that implements that following C# method for this purpose:

[WebMethod]
public TreeData GetTreeData(string controlId, string requestPath)

The name of this method is specified in the URL above. The parameters are:
  • controlId - the control identifier of the WebObjectTree instance.
  • requestPath - the path to the data required for the expanded item object.
The web service defines a helper class "TreeData" that is serialized to return the children item information in JSON format.

If the built-in Ajax encounters an error during the retrieval of information from the web service, it uses the following client-side method:

function cwotOnDataRetrievalError(controlId, statusCode, statusText)

This callback method can be implemented by you to allow reporting of the error to your users. WebObjectTree will automatically detect the presence of this method, and call it whenever it has trouble fetching data from the web service. The parameters are:
  • controlId - the control identifier of the WebObjectTree instance.
  • statusCode - the status code returned when retrieving children item information.
  • statusText - the status description returned when retrieving children item information.
Additionally, whenever WebObjectTree starts/stops retrieving data for any of the possible data retrieval modes it calls the following client-side callback methods:

function cwotOnDataRetrievalBegin(controlId)
function cwotOnDataRetrievalEnd(controlId)

These callback methods are demonstrated here by displaying the "Loading..." or "Ready" message.

In this sample the WebObjectTree is allowing you to select a datacenter server, organized by region, location and role. Clicking the "Submit" button will display the full path for your selection below:
Click the "Reset" link to clear your selection.
Control being used:
View the code:
The code is available in the samples directory under:
/DataRetrieval
    /BuiltinAjax