Hello community!
I'm working with the WebDataTree and I have a problem when I try to expand the Third Level Items.
First level gets loaded fine. Also the second level.
When I try to expand to the next level, an error occurs "Async request failed".
This reminds me of an error of the WebHierarchicalDataGrid.
Here is my code. And I also attached a working sample :)
Please kindly help me. I would appreciate it so much!
Sincerely,
George K.
Source code:
Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebDataTree._Default" %><%@ Register Assembly="Infragistics35.Web.v11.1, Version=11.1.20111.1006, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.NavigationControls" TagPrefix="ig" %><!DOCTYPE html><html> <head> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="scm" runat="server"></asp:ScriptManager> <asp:Button ID="btnLoad" runat="server" Text="Load Data" /> <ig:WebDataTree ID="wdtTestsGroups" runat="server" StyleSetName="Default" SelectionType="Single" BorderStyle="None" BorderWidth="0px" NodeIndent="26" EnableConnectorLines="True" Width="100%" Height="100%" CheckBoxMode="BiState" EnableAjaxViewState="False" OnNodePopulate="wdtTestsGroups_NodePopulate"> </ig:WebDataTree> </form> </body></html>
Default.aspx.vb
Protected Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click Dim dt As DataTable = GetTestGroups() wdtTestsGroups.Nodes.Clear() For Each row As DataRow In dt.Rows() If row("PARENTTESTGROUP_ID") Is DBNull.Value Then Dim dtn As New DataTreeNode() dtn.Key = row("TESTGROUP_ID") dtn.Text = row("DESCRIPTION") dtn.IsEmptyParent = True If Not row("DISABLESELECTION") Is DBNull.Value Then If Val(row("DISABLESELECTION")) = 1 Then dtn.Enabled = False dtn.IsEmptyParent = False End If End If wdtTestsGroups.Nodes.Add(dtn) End If Next End Sub
Protected Sub wdtTestsGroups_NodePopulate(sender As Object, e As Infragistics.Web.UI.NavigationControls.DataTreeNodeEventArgs) If e.Node.HasChildren Then Exit Sub Dim dtParents As DataTable = GetTestGroupsInTestGroups(e.Node.Key) Dim dtTests As DataTable = GetTestsInTestGroups(e.Node.Key) For Each row1 As DataRow In dtParents.Rows Dim dtn As New DataTreeNode() dtn.Key = row1("TESTGROUP_ID") dtn.Text = row1("DESCRIPTION") dtn.Populated = False dtn.IsEmptyParent = True If Not row1("DISABLESELECTION") Is DBNull.Value Then If Val(row1("DISABLESELECTION")) = 1 Then dtn.Enabled = False dtn.IsEmptyParent = False End If End If e.Node.Nodes.Add(dtn) Next For Each row2 As DataRow In dtTests.Rows Dim dtn As New DataTreeNode() dtn.Key = row2("TEST_ID") dtn.Text = row2("TESTNAME") e.Node.Nodes.Add(dtn) Next dtParents.Dispose() dtTests.Dispose() End Sub
Protected Function GetTestGroups() As DataTable Dim dt As New DataTable Dim query As String = "SELECT TESTGROUP_ID,DESCRIPTION,PARENTTESTGROUP_ID,DISABLESELECTION FROM TESTGROUPS WHERE PARENTTESTGROUP_ID IS NULL ORDER BY DESCRIPTION" Using cs As New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("CS").ConnectionString) cs.Open() Using cmd As New OleDbCommand(query, cs) Using da As New OleDbDataAdapter(cmd) da.Fill(dt) da.Dispose() End Using End Using cs.Close() End Using Return dt End Function Protected Function GetTestGroupsInTestGroups(ByVal id As Integer) As DataTable Dim dt As New DataTable Dim query As String = "SELECT TESTGROUP_ID,DESCRIPTION,PARENTTESTGROUP_ID,DISABLESELECTION FROM TESTGROUPS WHERE PARENTTESTGROUP_ID=" & id & " ORDER BY DESCRIPTION" Using cs As New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("CS").ConnectionString) cs.Open() Using cmd As New OleDbCommand(query, cs) Using da As New OleDbDataAdapter(cmd) da.Fill(dt) da.Dispose() End Using End Using cs.Close() End Using Return dt End Function Protected Function GetTestsInTestGroups(ByVal id As Integer) As DataTable Dim dt As New DataTable Dim query As String = "SELECT TESTS.TEST_ID,TESTNAME FROM TESTS INNER JOIN TESTGROUPS_TESTS ON TESTS.TEST_ID=TESTGROUPS_TESTS.TEST_ID WHERE TESTGROUP_ID=" & id & " ORDER BY TESTNAME" Using cs As New OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings("CS").ConnectionString) cs.Open() Using cmd As New OleDbCommand(query, cs) Using da As New OleDbDataAdapter(cmd) da.Fill(dt) da.Dispose() End Using End Using cs.Close() End Using Return dt End Function
Hello George,
Thank you for contacting Infragistics!
I have done some looking into this matter and have some questions concerning this matter:
What is the full error message you are receiving?It seems your sample demonstrating your issue failed to attach, would you be able to attach it again? When attaching please make sure to remove the bin and ig_res folder and put the remaining files in a compressed zip folder.
Hello Mike P and thank you for your answer :)
Yes, I totally forgot to attach my sample project. I removed the files as you wanted.
The exact error message is: Async request failed. Reminds me of the error I had in the WebHierarchicalDataGrid.
Another problem I noticed: When I click on the button to get the selected nodes, the property .CheckedNodes of the WebDataTree returns only the checked nodes from the first level. Please try to select the child nodes TEST 1, TEST 2, TEST 3 from the GROUP 1. After that click on the button "Get selected nodes". It returns nothing... :(
Please take a look and I hope we can solve it :)
Thank you for the update and sample. I have done some looking into this matter, both behaviors you are seeing appear to be happening because the child data isn’t being maintained. Once a postback occurs only the parent level data remains. I am currently looking further into this matter to see why this behavior is occurring. I will continue to look into this matter and will update you with my progress.
Thank you Mike. I'm gonna wait for your update.
Hello Geroge,
Thank you for your patience. The reason you are seeing this behavior is you set EnableAjaxViewState to false. This property allows the WebDataTree to maintain its state through postback:
http://help.infragistics.com/doc/ASPNET/2015.1/CLR4.0/?page=Infragistics4.Web.v15.1~Infragistics.Web.UI.Framework.Data.HierarchicalDataBoundControlMain~EnableAjaxViewState.html
Please let me know if you have any further questions concerning this matter.
Thank you very much, Mike.
This solves the problem :)