Community
Blogs
This space is available to any ComponentArt employee to write about anything.
RSS
About Me
Browse by Tags
All Tags
»
treeview
(RSS)
ASP.NET AJAX
Load on demand
navigation
Web Service
web services
Web.UI
4
Comments
1281 Views
TreeView and Web Services
In my previous post , I talked about the web service functionality that's common to all ComponentArt navigation controls. I focused on common features that are present in many different controls, especially in this case, but this approach was unfair to one control. With its ability to load chunks of data on demand, TreeView is the odd man out, supporting everything that other navigation controls do, but adding its own unique twist. Like the other navigation controls, TreeView has control-level WebService and WebServiceMethod properties. These determine which ASP.NET AJAX registered web service will be called, and which method of that service, when nodes are retrieved. For the initial data load, the behaviour is identical to Menu, TabStrip or NavBar. What TreeView can do that others can not is to only load some nodes initially, letting user actions determine what else gets loaded and when. Essentially, TreeView is able to operate in load-on-demand mode with web services. To return load-on-demand nodes (parent nodes with no child nodes pre-loaded), simply set their UseWebService property to true. This will notify TreeView to consider these nodes to be parent nodes, and to call the web service again when they are expanded, to load their child nodes. When that happens, the same WebServiceMethod will be called, but with a twist: the TreeViewWebServiceRequest object that is passed in will have its Node property set to the node that requires data. Based on the Text, Value or ID of this node, appropriate new nodes can be created and returned, as they would normally, from the web service method. Note that these child nodes can also have their UseWebService property set to true. After a web service call completes, the client-side event also exposes the node for which the call was made, in addition to the customData property common to all navigation controls. Here's an overview of the client-side TreeViewNodeWebServiceCompleteEventArgs class: function TreeView1_webServiceComplete(sender, eventArgs) { var node = eventArgs.get_node(); if(node) { alert('Completed web service call for node ' + node.get_text()); } else { alert('Completed web service call for top level data.'); } var customData = eventArgs.get_customData(); if(customData) { alert('Web service call returned custom data: ' + customData); } } You can see an example of this functionality online with the TreeView Web Service Load-on-demand sample . Please note that this functionality is fully available only as of Web.UI 2008.1 SP1, released on April 23rd 2008. Summary To recap, since TreeView can load node-specific partial data through web services (unlike other navigation controls, which can only load all the items at once), its related API is a superset of, say, that of Menu. TreeViewWebServiceRequest includes the Node property (null for initial, top-level loading), TreeViewNode has the UseWebService boolean, and the client-side TreeViewWebServiceCompleteEventArgs class includes a node property. These extensions enable efficient load-on-demand functionality built entirely on ASP.NET AJAX web services. Share this post: email it! | bookmark it! | digg it! | reddit!
Posted by:
Milos
Posted:
Wednesday, April 23, 2008 10:49 AM
Filed under:
Web.UI
,
treeview
,
web services
,
Load on demand
4 Comments
0
Comments
1103 Views
Web Service Data Loading with Navigation Controls
Previously, I have written about Grid’s new WebService running mode, which allows Grid to communicate with an ASP.NET AJAX web service directly from the client, and do all its data loading through it, including paging, sorting, filtering, etc. This powerful functionality is also available on ComponentArt navigation controls: TreeView, Menu, NavBar, TabStrip and ToolBar. All of these have the ability to load their data from an ASP.NET AJAX web service. TreeView, furthermore, has the ability to load data for each node on demand. Since this functionality is a superset of the simple ability to fetch all the data at once, I’ll outline the more complex case here. - On the server, we use the WebService and WebServiceMethod properties to set the name of the registered web service to use, as well as the name of the method to invoke to retrieve node data. - The service WebMethod refered to by the control’s WebServiceMethod property should be implemented with the following signature: public TreeViewWebServiceResponse MethodName(TreeViewWebServiceRequest request) The above example is for TreeView – for other controls, the appropriate types should be used, eg. TabStripWebServiceResponse and TabStripWebServiceRequest for TabStrip. - The method’s return value (a *WebServiceResponse) should contain the nodes to be sent to the control. At this point, the work of defining a web service data source for a navigation control is complete. With the above setup, the control will fetch its data from the specified web service by invoking the specified method. With TreeView, we often wish to configure data loading using an on-demand mechanism. This means that a node’s children are loaded only when that node is expanded and no sooner. To achieve this, we only need one additional step: - Instead of populating a TreeViewNode with its child nodes, set its UseWebService property to true to specify that the web service should be used to fetch its child nodes. When this is done, the same WebServiceMethod will be invoked as for the root nodes, but the TreeViewWebServiceRequest’s Node property will be set to the TreeViewNode which needs to be populated. That’s all there is to it. Note: All the navigation controls also have a WebServiceCustomParameter which can be set on the server or the client, and which is sent back as part of every *WebServiceRequest. This should allow for custom context-dependant data loading. For a simple demo of this functionality, check out the Web Service Creation sample on our site. For a look at web service-driven TreeView load-on-demand, take a look at this TreeView sample . A useful real-world application using TreeView and Grid, build entirely on web services, can be seen in the Full Web Service Application sample. Share this post: email it! | bookmark it! | digg it! | reddit!
Posted by:
Milos
Posted:
Tuesday, December 18, 2007 8:18 AM
Filed under:
ASP.NET AJAX
,
Web Service
,
Web.UI
,
navigation
,
treeview
0 Comments
Blogs On This Site
Miljan Braticevic
Thoughts on web user interfaces and component development.
Jovan's Blog
Ramblings of a web control developer.
The Blog of Milos
Web.UI news and more
Evan's Safari Planet
Next weeks guest: A dog and a baby dog!
Stephen Hatcher
I'm in your base, killing your dudes.
Phil Tucker
Absurdity is it's own message.
Filip Karadzic
Musings of an ex Java developer
Breon's Blog
im in ur page, hackin ur codez
Milena Braticevic
ComponentArt in the Community
Bojan Jovanovic
... and the program ran happily ever after.
This Blog
Home
About
Links
Subscriptions
RSS 2.0
Atom 1.0
Recent Posts
Web.UI 2008.2 Grid News: Grouping
Grid Configuration via Web Service
AJAX With ASP.NET MVC and ComponentArt CallBack
TreeView and Web Services
Web.UI Navigation Controls and Web Services
Archives
September 2008 (1)
June 2008 (1)
May 2008 (1)
April 2008 (2)
March 2008 (2)
December 2007 (2)
November 2007 (3)
October 2007 (1)
May 2007 (1)
January 2007 (1)
November 2006 (3)
ComponentArt and Web.UI are trademarks of ComponentArt Inc. Copyright © 2000-2006. All Rights Reserved.