[CLOSED] Access TreeGrid nodes from DirectEvent handler

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Access TreeGrid nodes from DirectEvent handler

    I have a direct event handler that needs to iterate through the nodes that are in a TreeGrid, but when I inspect TheGrid.Root, it's empty. Is there something special I need to do to be able to get to those nodes?
  2. #2

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    Hello, jmcantrell!

    Please look at the example.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Access TreeGrid nodes from DirectEvent.aspx.cs"
        Inherits="Work.Premium_help.Access_TreeGrid_nodes_from_DirectEvent" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Button_Click(object sender, EventArgs args)
        {
            X.MessageBox.Alert("TheGrid.Root", TheGrid.Root.ToString()).Show();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <ext:ResourceManager runat="server">
        </ext:ResourceManager>
        <ext:TreeGrid ID="TheGrid" runat="server">
            <Columns>
                <ext:TreeGridColumn Header="Column" Width="100">
                </ext:TreeGridColumn>
            </Columns>
            <Root>
                <ext:TreeNode>
                </ext:TreeNode>
            </Root>
        </ext:TreeGrid>
        <ext:Button runat="server" Text="Click to show the TheGrid.Root">
            <DirectEvents>
                <Click OnEvent="Button_Click" />
            </DirectEvents>
        </ext:Button>
    </body>
    </html>
    Please note the Root is not empty in this example.
    So, could you provide me with your example where the Root is empty.

  3. #3

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler


  4. #4

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    i assume when you are saying tree.Root you are actually inspecting tree.root (lower case) right?

    otherwise i have this same thing in my code and it works (unless it broke with an update?)

                    tree.root.eachChild
                    (
                        function fn(node) {
                            //do something
                        }
                    );
    I dont have my root visible either so i would think that shouldn't be an issue?
  5. #5

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    Hello, bryantharpe!

    I think he means the accessing the Root in a code behind. He uses the DirectEvent.
    Today I updated from the SVN repository and it stiil works fine.
  6. #6

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    oh right! small details.. lol
  7. #7

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    Anything is possible:)
  8. #8

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    This should not be marked as solved. See my code below...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
    
        <script runat="server">
            
            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                If Not IsPostBack And Not Ext.Net.X.IsAjaxRequest Then
                    BuildTree(TheGrid.Root)
                End If
            End Sub
    
    
            Protected Function BuildTree(ByVal nodes As Ext.Net.TreeNodeCollection) As Ext.Net.TreeNodeCollection
                If nodes Is Nothing Then nodes = New Ext.Net.TreeNodeCollection
    
    
                Dim root As New Ext.Net.TreeNode("Root")
                nodes.Add(root)
    
    
                For i = 1 To 10
                    Dim node As New Ext.Net.TreeNode("Test " &amp; i)
                    node.CustomAttributes.Add(New Ext.Net.ConfigItem("foo", CStr(i), Ext.Net.ParameterMode.Value))
                    root.Nodes.Add(node)
                Next
    
    
                Return nodes
            End Function
    
    
            Public Sub PrintButton_Click(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
                Dim x = TheGrid.Root.Count '<== This is zero
            End Sub
    
    
        </script>
    
    
    </head>
    <body>
        <form id="form1" runat="server">
        
            <ext:ResourceManager runat="server" />
            <ext:Panel ID="grid" runat="server" Layout="Card" ActiveIndex="0" Border="false">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:Button ID="btnPrint" runat="server" Text="Print" Icon="Printer">
                                <DirectEvents>
                                    <Click OnEvent="PrintButton_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="Type" Value="PDF" />
                                        </ExtraParams>
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Items>
                    <ext:TreeGrid ID="TheGrid" runat="server" Border="false" NoLeafIcon="true">
                        <Columns>
                            <ext:TreeGridColumn Header="Foo" Width="150" DataIndex="foo" />
                        </Columns>
                    </ext:TreeGrid>
                </Items>
            </ext:Panel>
        
    
        </form>
    </body>
    </html>
  9. #9

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    Hello, jmcantrell!

    If you want to access to the columns in the TreeGrid class please use the TheGrid.Columns property. Not the TheGrid.Root.
    So, there is no any <Root> in your TreeGrid and it's no strange that the TreeGrid.Root is null.

    I didn't adapt to this class at once, also as you:)
  10. #10

    RE: [CLOSED] Access TreeGrid nodes from DirectEvent handler

    I'm trying to get access to the nodes, and there is a root, it's just defined in the code behind, not the markup.
Page 1 of 2 12 LastLast

Similar Threads

  1. Custom TreeGrid nodes ?
    By Mohammad in forum 1.x Help
    Replies: 18
    Last Post: Aug 22, 2012, 9:49 AM
  2. Replies: 1
    Last Post: Jun 09, 2011, 7:04 PM
  3. [CLOSED] TreeGrid example on examples.ext.net does not show any nodes
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 24, 2010, 4:44 PM
  4. [CLOSED] Access TriggerEventArgs from DirectEvent Handler
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 06, 2010, 6:39 PM
  5. [CLOSED] Store XmlReader - how to access parent nodes?
    By mrozik in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 09, 2010, 6:47 AM

Posting Permissions