[CLOSED] TreeStore with IHierarchicalDataSource

  1. #1

    [CLOSED] TreeStore with IHierarchicalDataSource

    Hi,
    I'm trying to bind a TreePanel's Store with a IHierarchicalDataSource with this (VB.NET) code:

            sender.Store(0).DataSource = New AttivitaHDataSource(GetDTAttivita(AddressOf adapter.Attivita.Fill))
            sender.Store(0).DataBind()
    AttivitaHDataSource is a hierarchical data source built from a datatable. The constructor's argument is the datatable.
    This approach works just fine with an ASP.NET TreeView, but with the TreeStore I get a NullReferenceException at the .DataBind() step.

    Is this supported? I haven't found much documentation. Can you provide an example?

    Motivation: I follow this approach to refresh the content of a GridPanel with server-side code and I'd rather do the same with the TreePanel than reload with client-side code.

    Thanks!
    Last edited by Daniil; Nov 01, 2013 at 5:03 AM. Reason: [CLOSED]
  2. #2
    Hi @bbros,

    Binding an IHierarchicalDataSource to a TreeStore is supported.

    Here is an example.
    https://examples2.ext.net/#/TreePane..._File_Loading/

    So, you should probably configure a TreeStore's DataBindings.
  3. #3
    Quote Originally Posted by Daniil View Post
    So, you should probably configure a TreeStore's DataBindings.
    Thanks, but that didn't work; I still get the null reference exception.
    I switched to client-side refreshing, following this example:

    https://examples2.ext.net/#/TreePane...h_Static_Tree/

    It works fine.
  4. #4
    Quote Originally Posted by bbros View Post
    Thanks, but that didn't work; I still get the null reference exception.
    If you can provide a test case, we would be glad to investigate.


    Quote Originally Posted by bbros View Post
    I switched to client-side refreshing, following this example:

    https://examples2.ext.net/#/TreePane...h_Static_Tree/

    It works fine.
    Nice!
  5. #5
    Quote Originally Posted by Daniil View Post
    If you can provide a test case, we would be glad to investigate.
    With pleasure. I put together a sample project and uploaded it here (the forum won't let me attach zip files):

    http://ge.tt/api/1/files/6Cily9w/0/blob?download

    In this project:
    • the page TreeView.aspx contains an ASP.NET TreeView control that works
    • the Default.aspx page contains a TreePanel that causes the null reference exception with the same hierarchical datasource
  6. #6
    Thank you. We are investigating.

    P.S. It is better to post the code samples directly here wrapping in code tags. Sure, it should be simplified/minified before.
  7. #7
    Can you post TreeView.aspx with DataBindings (to read Attivita field as text)?
  8. #8
    Quote Originally Posted by Vladimir View Post
    Can you post TreeView.aspx with DataBindings (to read Attivita field as text)?
    I'm not sure I understand, sorry.

    The datatable is defined in the Common.vb file as follows:

       
            Dim dt = New DataSet1.AttivitaDataTable
    
            With dt
                Dim row1 = .NewAttivitaRow
                row1.idAttivita = 1
                row1.Attivita = "a"
                .AddAttivitaRow(row1)
    
                Dim row2 = .NewAttivitaRow
                row2.idAttivita = 2
                row2.Attivita = "b"
                .AddAttivitaRow(row2)
    
                Dim row3 = .NewAttivitaRow
                row3.idAttivita = 3
                row3.idAttivitaParent = 1
                row3.Attivita = "c"
                .AddAttivitaRow(row3)
            End With
    and this is what the TreeView shows:

    Click image for larger version. 

Name:	TreeView.PNG 
Views:	16 
Size:	26.4 KB 
ID:	7121

    So the TreeView is already showing the Attivita field as text: "a", "b" and "c" are the Attivita fields in the three records (I could have chosen better examples, sure).

    Did you mean something else?

    P.S. The databinding for the TreeView is in the code behind:

    Public Class TreeView
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            TreeView1.DataSource = Common.GetHDS
            TreeView1.DataBind()
        End Sub
    
    End Class
    Common.GetHDS returns a hierarchical data source (implementing the IHierarchicalDataSource interface) built from the datatable defined above.
    Last edited by bbros; Oct 26, 2013 at 8:45 AM.
  9. #9
    Your TreeView sample has no any defined DataBindings, it means that TreeView will use ToString method for items (without reading any additinal fields)

    If you update from SVN then Ext.Net can work with your data without defined DataBindings (like in TreeView sample)
    Imports Ext.Net
    
    
    Public Class _Default
        Inherits System.Web.UI.Page
    
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim s = New TreeStore With {.ID = "AttivitaTreeStore"}
            Dim tp = New TreePanel With {.ID = "TP"}
            tp.Store.Add(s)
            Me.Controls.Add(tp)
    
    
            tp.GetStore.DataSource = Common.GetHDS
            tp.DataBind()
    
    
        End Sub
    
    
    End Class
    If you need any additional fields then you have to define DataBindings. I am not sure what exactly DataMember should be defined in DataBinding therefore I asked about ASP.NET sample with TreeView where DataBindings is used

Similar Threads

  1. [CLOSED] there is no remove method in treestore?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 23, 2013, 6:20 AM
  2. [CLOSED] TreeStore issue with 2.2
    By paulc in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 19, 2013, 9:24 AM
  3. Replies: 10
    Last Post: May 31, 2013, 12:54 PM
  4. Replies: 3
    Last Post: Apr 10, 2013, 4:05 AM
  5. [CLOSED] TreePanel & TreeStore setRootNode() not working anymore?
    By cleve in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2013, 3:16 PM

Tags for this Thread

Posting Permissions