WebDataTree with enabled load-on-demand does not work with WebhierarchyDataSource with Self-Related Data Relation.
Is it bug or feature?
Vladimir
Vladimir,
I am assuming you are talking about the Infragistics WebHierarchicalDataSource.
This feature should work fine. Did you set up a DataBinding on the tree for the datasource. The following code for me brings the first level in initially and fetches subsequent ones. What exactly was the problem you experienced? No data? All data at the start?
<ig:WebDataTree ID="WebDataTree1" runat="server" Height="300px" Width="200px" DataSourceID="WebHierarchicalDataSource1" InitialDataBindDepth="0"> <DataBindings> <ig:DataTreeNodeBinding DataMember="AccessDataSource1_DefaultView" TextField="TextValue" ValueField="Code" /> </DataBindings> </ig:WebDataTree> <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server"> <DataRelations> <ig:DataRelation ChildColumns="ParentCode" ChildDataViewID="AccessDataSource1_DefaultView" ParentColumns="Code" ParentDataViewID="AccessDataSource1_DefaultView" /> </DataRelations> <DataViews> <ig:Dataview id="AccessDataSource1_DefaultView" datamember="DefaultView" datasourceid="AccessDataSource1"> </ig:Dataview> </DataViews> </ig:WebHierarchicalDataSource> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/TreeData.mdb" SelectCommand="SELECT [Code], [TextValue], [ParentCode] FROM [Data]"> </asp:AccessDataSource>
regards,
David Young
Yes
That example is working.
I was trying to use codebehand and it does not work
Here is my aspx
-----START ASPX -------
>
----- END ASPX -----------
Then
view =
New DataView
view.ID =
"DefailtView"
view.DataSourceID =
Me.AccessDataSource1.ID
view.DataMember =
relation =
New DataRelation
relation.ChildColumns =
New String() {"ParentCode"}
relation.ChildDataViewID = view.ID
relation.ParentColumns =
New String() {"Code"}
relation.ParentDataViewID = view.ID
binding =
New DataTreeNodeBinding
binding.DataMember = view.ID
binding.TextField =
"TextValue"
binding.ValueField =
"Code"
--- START CODE BEHIND ---
--- END CODE BEHIND --
Hi Vladimir,
when using the code-behind you should also bind the tree on the NodePopulate event.
could you prived the final codebehind code?
Hi Nikola
I am having the issue with the same i get the data using stored proc and then i want to bind the data ondemand in the codebehind but that is failing.
Can you please point me to the right direction
Regards
Raghu
Thanks Nikola
That works
Another question - how can I change images (+, -) in codebehind?
Thanks,
Sure, here it is:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Me.Page.IsPostBack Then
SetupDataSource()
Dim view As DataView view = New DataView view.ID = "DefailtView" view.DataSourceID = Me.AccessDataSource1.ID view.DataMember = "DefailtView" Me.WebHierarchicalDataSource1.DataViews.Add(view)
Dim relation As DataRelation relation = New DataRelation
relation.ChildColumns = New String() {"ParentCode"} relation.ChildDataViewID = view.ID relation.ParentColumns = New String() {"Code"} relation.ParentDataViewID = view.ID
Me.WebHierarchicalDataSource1.DataRelations.Add(relation) Me.WebDataTree1.InitialDataBindDepth = 0 Me.WebDataTree1.DataLoadingMessage = "Loading from table ..." Me.WebDataTree1.DataSourceID = Me.WebHierarchicalDataSource1.ID End If End Sub
Protected Sub WebDataTree1_NodePopulate(ByVal sender As Object, ByVal e As Infragistics.Web.UI.NavigationControls.DataTreeNodeEventArgs) Handles WebDataTree1.NodePopulate SetupDataSource() End Sub
Private Sub SetupDataSource() Me.AccessDataSource1.DataFile = "~/App_Data/TreeData.mdb" Me.AccessDataSource1.SelectCommand = "SELECT [Code], [TextValue], [ParentCode] FROM [Data]"
Dim binding As DataTreeNodeBinding binding = New DataTreeNodeBinding binding.DataMember = "DefailtView" binding.TextField = "TextValue" binding.ValueField = "Code" Me.WebDataTree1.DataBindings.Add(binding) End Sub
Hope that helps!