[CLOSED] HOW TO make a client-side refresh of a TreeNode in a TreePanel - EXT.NET 2.4.x

  1. #1

    [CLOSED] HOW TO make a client-side refresh of a TreeNode in a TreePanel - EXT.NET 2.4.x

    Hello,
    I'm using EXT.NET 2.4.0.28408 and i'm trying to refresh a node in a tree panel, after a value to compile a field of a column belonging to the panel is inserted from a prompt panel.
    The treepanel is in an empty .ascx file and it's dynamically built using a web service.

    <ext:Panel runat="server" ID="parametriIN"  Width="650" Height="450">
        <Items>
            <ext:TreePanel ID="treeOBJ" runat="server" Title="Parametri in ingresso"
                Icon="BookOpen" RootVisible="false"
                Width="650" Height="300" AutoScroll="true">
                <Root>            
                </Root>
                <Fields>
                    <ext:ModelField Name="text" />
                    <ext:ModelField Name="Type" />
                    <ext:ModelField Name="Value" />
                </Fields>
                <ColumnModel>
                    <Columns>
                        <ext:TreeColumn ID="TreeColumn1" runat="server" Header="Parameter name" Flex="1" DataIndex="text"/>
                        <ext:Column ID="ColonnaTipo" runat="server" Header="Type" Width="150" DataIndex="Type"/>
                        <ext:Column ID="ColonnaValore" runat="server" Header="Value" Width="250" DataIndex="Value" ToolTip=""></ext:Column>
                        <ext:CommandColumn ID="CommandColumn1" Header="" runat="server" Width="40">
                            <Commands>
                                <ext:GridCommand CommandName="Edit" Icon="PageWhiteEdit" ToolTip-Title="Set value" ToolTip-Text="Set value" />
                            </Commands>
                            <PrepareToolbar Handler="return record.data.leaf;" />
                            <Listeners>
                                <Command Handler="valorize(record);" />
                            </Listeners>
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:StatusBar ID="StatusBar1" runat="server" AutoClear="1500" />
                </BottomBar>
                <Listeners>
                    <ItemClick
                        Handler="#{StatusBar1}.setStatus({text: 'Selected node: <b>' + record.data.text + '<br />', clear: false});"                     
                        />
                </Listeners>
           
            </ext:TreePanel>
        </Items>
    </ext:Panel>
    here we have the page load of the .ascx file, where objectWS is an object containg due properties called "Name" and "Type":

         Private Class objectWS
            Private _name As String
            Public Property Name() As String
                Get
                    Return _name
                End Get
                Set(ByVal value As String)
                    _name = value
                End Set
            End Property
            Private _type As String
            Public Property Type() As String
                Get
                    Return _type
                End Get
                Set(ByVal value As String)
                    _type = value
                End Set
            End Property
            Public Sub New()
            End Sub
            Public Sub New(n As String, t As String)
                _name = n
                _type = t
            End Sub
        End Class
    
        Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
            Dim root As New Ext.Net.Node
            Dim objs As New List(Of objectWS)
    
            root.Text = "Parameters"
            treeOBJ.Root.Add(root)
    
            objs.Add(New objectWS("user", "System.String"))
            objs.Add(New objectWS("psw", "System.String"))
    
            For Each ob As objectWS In objs
                Dim node As New Ext.Net.Node
                node.Text = ob.Name
                If BaseType(ob.type) Then
                    node.Leaf = True
                    node.Icon = Icon.Add
                    node.CustomAttributes.Add(New Ext.Net.ConfigItem("Type", ob.Type, ParameterMode.Value))
                    node.CustomAttributes.Add(New Ext.Net.ConfigItem("Value", "", ParameterMode.Value))
                Else
                    node.Icon = Icon.Package
                    'addStruct(node, ob.type)
                End If
    
                root.Children.Add(node)
            Next
    
            Try
                treeOBJ.ExpandAll()
            Catch ex As Exception
            End Try
        End Sub
    
        Private Function BaseType(type As String) As Boolean
            If type = "System.String" Then
                Return True
            Else
                Return False
            End If
        End Function
    And this is few javascript to refresh the node of the panel:
    function valorizeTree(btn, text, node) {
        if (btn == "ok" && (text != null || text != "")) {
            node.data.Value = text;
            node.reload;
        }
    }
    
    function valorize(node) {
        Ext.Msg.prompt('Set parameter', 'Write parameter value "' + node.data.text + '":', function (btn, text) { valorizeTree(btn, text, node); }, this, false);
    }
    The problem is that the value is correctly assigned to the field, but nothing is then visualized.
    Here you have a small screenshot.


    Click image for larger version. 

Name:	prompt.jpg 
Views:	12 
Size:	16.1 KB 
ID:	7541


    Thank you in advance.
    Last edited by Daniil; Jan 30, 2014 at 2:55 AM. Reason: [CLOSED]
  2. #2
    Hi @PoloTheMonk,

    A node's reload method should be used only if there is a TreeStore with a Proxy.

    Please use the set method:
    node.set("Value", text);
    instead of
    node.data.Value = text;
    Also please note that this
    node.reload;
    doesn't do anything at all. To call a JavaScript function, the brackets are required.
    node.reload();
    Though, as I said, you should not use the reload method.
  3. #3
    It works!

    Thank you very much.

Similar Threads

  1. Replies: 9
    Last Post: Dec 29, 2012, 1:02 AM
  2. Replies: 6
    Last Post: Oct 07, 2012, 5:14 PM
  3. [CLOSED] How to refresh a TreeNode (attribute) in a TreePanel
    By macap in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Aug 16, 2012, 3:41 PM
  4. Replies: 1
    Last Post: Jan 24, 2012, 1:40 PM
  5. Replies: 0
    Last Post: Mar 30, 2011, 7:34 AM

Tags for this Thread

Posting Permissions