Hello,
I've just started using the UltraWebTree and am having difficulties. However, I'd like to ask about how the tree works with Ajax. From looking at the samples, I can see that you can use manual and automatic modes. But, what is the significance of this? From what I can see, the manual mode requires the DemandLoad event to be populated. But this begs the question: what has this got to do with Ajax? If the tree is simply populating based on an ASP event, isn't this just straight ASP, and not Ajax?
Looking at the automatic mode code (from the samples page), I can't really see how it is working. It shows some setup code, but it doesn't provide any web methods or JavaScript code to explain how to populate the tree with Ajax.
This is the Page_Load code.
WebPanel2.Visible = WebSamplesCS.Config.ShowDescription; // When the LoadOnDemand property is set to Automatic, // the database must be bound on each postback. // Get Database connection path for nwind.mdb oleDbConnection1.ConnectionString = WebSamplesCS.Config.NorthwindMDBConnString; customersAdapter.Fill(dataSet11, "Customers"); ordersAdapter.Fill(dataSet11, "Orders"); orderDetailsAdapter.Fill(dataSet11, "Order Details"); try { dataSet11.Relations.Add("CustOrders", dataSet11.Tables["Customers"].Columns["CustomerID"], dataSet11.Tables["Orders"].Columns["CustomerID"]); } catch (System.Exception x) { string s = x.Message; Label1.Text = x.Message; } try { dataSet11.Relations.Add("OrderDetails", dataSet11.Tables["Orders"].Columns["OrderID"], dataSet11.Tables["Order Details"].Columns["OrderID"]); } catch (System.Exception x) { Label1.Text = x.Message; } this.UltraWebTree1.DataSource = dataSet11; this.UltraWebTree1.Levels[0].RelationName = "CustOrders"; this.UltraWebTree1.Levels[0].ColumnName = "CompanyName"; this.UltraWebTree1.Levels[1].RelationName = "OrderDetails"; this.UltraWebTree1.Levels[1].ColumnName = "OrderId"; this.UltraWebTree1.Levels[2].ColumnName = "ProductId"; this.UltraWebTree1.DataMember = "Customers"; this.UltraWebTree1.DataBind();
This is great if your dataset is relational data tables. But, we don't use anything like that. We have our own object model.
So the question is, how can we get the control to use proper Ajax with our object model?
Thanks for the follow-up. Yes, I agree - ASP.NET event handlers are called after Page_Load and the whole lifecycle of the page will be executed up to the point where the event handler is called. I think this is not a very big overhead, since you can move the heavy initializing code in If Not Page.IsPostBack code blocks and the overhead should be minimal.
So yes, WCF / WebMethod calls are currently not supported out of the box. The closest I can think to that is to use the ASP.NET AJAX Client-Side API (it provides API classes for calling WCF / WebMethods) to retrieve that data and then use the Add nodes client-side functioanlity of the treeview (via our CSOM - client side object model) to add the info from WebMethod / WCF to the node.
WebMethod / WCF calls are certainly a good idea - but I am afraid they will be supported in future versions of the product.
"So just think of these event handlers as similar to WebMethods, they essentially do the same thing."
That is incorrect. By using ASP events, the Page_Load event is also fired on the ASP server. I.e. a partial postback occurs. This does not occur with web methods. This is an extra overhead.
There is also an architectural reason to why you would use WebMethods as opposed to ASP events. If you wanted to create an alternative physical layer to serve up live data, it would be impossible in this situation. For example, I have a WCF layer in my application. I want my controls to talk directly to the WCF layer. Or in some cases I may want to create a separate service which talks to the WCF layer (this may be on another machine for scalability reasons). With the current method, this would be unachievable because the Infragistics control would always talk to my ASP server, and not my WCF server or other server.
DemandLoad is indeed an event handler, but called asynchronously. The reason we are using event handlers is that they are simply easier to use (double click in design mode and that is it) - you get the respective parameters and handlers autogenerated. With WebMethods you need to know the exact structure of the XML/JSON passed from server to client, much harder to write.
So just think of these event handlers as similar to WebMethods, they essentially do the same thing.
As for the question how the different load on demand modes work, I think this article explains it best:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9685
Each mode comes with its cons and pros, and you can pick one depending on your sceanrio.
Come to think of it, the same question goes for the UltraWebGrid. I looked at this code:
http://samples.infragistics.com/2008.2/webfeaturebrowser/default.htm
But from what I can see, you have to specify the way the data works using a series of data tables and relations etc. That just doesn't fit our model at all.
The kind of model we need is one where you initialise the Tree/Grid, and then when the control asks for data, a WebMethod is provided to serve up the data to the control. That way there are 0 postbacks and you don't have to load all the data on the server side on the initialisation of the control.
Am I barking up the wrong tree here? Is there something I'm missing?