[CLOSED] TreePanel direct event SelectionChange Get custom attributes server side

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] TreePanel direct event SelectionChange Get custom attributes server side

    Hi,
    I have a Treepanel with custom attributes on the nodes, how could I access to the custom attributes of the selected node on the selection_change direct event?

    I tried but I can access only to proxy server side objects without the direct access to the custom attributes.

    Thank you for your help!

    Here above there is the code.. up to now.. very empty..

    Here the code of the node custom attributes initialization..

     Ext.Net.Node node = new Ext.Net.Node()
                {
                    Text = Convert.ToString(r["DescriptionShort"]),
                    Icon = Icon.Folder,
                    Expandable = false
                    
                };
                node.CustomAttributes.Add(new ConfigItem("Id_iNV2_AM", Convert.ToString(r["Id_iNV2_AM"])));
    The direct method..

    
    
        protected void TreeFiltered_SelectionChange(object sender, DirectEventArgs e)
        {
            string s = e.ExtraParams["Node"].ToString();
        }
    <ext:TreePanel ID="TreeFiltered" 
                        runat="server" 
                        EnableDrag="true"                            
                        DDGroup="tree2div"
                        Region="West"
                        Split="true"
                        Margins="5 0 5 5"
                        Width="200"
                        Title="Albero topologico"
                        AutoScroll="true"
                        Collapsible="true">
                         <DirectEvents>                        <SelectionChange OnEvent="TreeFiltered_SelectionChange">
                                <ExtraParams>
                                    <ext:Parameter Name="Node" Value="node.attributes.Id_iNV2_AM" Mode="Raw" />
                                </ExtraParams>
                            </SelectionChange>
                        </DirectEvents>   
                    </ext:TreePanel>
    Last edited by Daniil; Feb 11, 2014 at 3:06 PM. Reason: [CLOSED]
  2. #2
    Hi @John_Writers,

    Please use
    node.data.Id_iNV2_AM
    instead of
    node.attributes.Id_iNV2_AM
  3. #3
    Hi,
    I tried but client side there is a javascript error:

    'node is undefined'

    So I looked in the javascript and the code is injected in the following function

    {"selectionchange":{fn:function(item,selected){Ext.net.directRequest({"extraParams":{"Node":node.data.Id_iNV2_AM},control:this,action:'SelectionChange'});}
    node was undefined in that function, then I tried to use:

    item.data.Id_iNV2_AM
    and after
    item.attributes.Id_iNV2_AM
    without success in both cases.

    Looking also in the quick watch, I didn't find the field I'm looking for...

    Something in the object design of ext.js is changed in the latest releases? I'm using ext.net 2.4 installed from nuGet.

    Thanks for your help.
    Last edited by John_Writers; Feb 04, 2014 at 12:36 PM.
  4. #4
    Yes, there is no "node" parameter. There is the "selected" parameter. It is an array of selected nodes.
    http://docs.sencha.com/extjs/4.2.1/#...electionchange
  5. #5
    Yes,
    I looked at this reference but I can't find a way to get those custom attributes.

    How can I figure out?

    Thank you for your time.
  6. #6
    How many nodes are supposed to be selected? If the only one, then it can look:
    selected[0].data.Id_iNV2_AM
    But if there is no selected nodes (all ones are deselected), it will throw an error, because the "selected" array will be empty.
  7. #7
    I tried also that, but it didn't work.

    So I changed event from "Selectionchange" to "Select"..

    Now in the Select event client side I have more objects accessible. ('item' and 'record')

    
    {"select":{fn:function(item,record,index)
    {Ext.net.directRequest({"extraParams":{"Node":item.data.ID_INV_REGISTRY},control:this,action:'Select'});}
    Then I tried to look for the custom parameter going deep in every object without find nothing.

    If it's not possible, I just need to:
    store custom fields on the Ext.Net.Node in a tree panel,
    when I select a node of the tree run code in a server side method,
    retrieve server side my data saved on the selected node.

    Looking on the forum I think using custom attributes is the right way to do that..

    Do you have any other idea?

    Thanks
  8. #8
    It looks that you didn't defined ModelFields for custom attributes.

    Please see the TreePanel's Fields section:
    https://examples2.ext.net/#/TreePane...nced/TreeGrid/

    If you have a TreeStore defined, you should define ModelFields for a TreeStore's Model.
  9. #9
    Great!

    That was the problem.

    Now I can access to the custom attributes with

                        <DirectEvents>
                            <Select OnEvent="TreeFiltered_Select">
                                <ExtraParams>
                                    <ext:Parameter Name="ID_INV_REGISTRY" Value="record.raw.ID_INV_REGISTRY" Mode="Raw" />
                                </ExtraParams>
                            </Select>
                        </DirectEvents>
    Thanks!
  10. #10
    It is better to use a record's data instead of raw.
    record.data.ID_INV_REGISTRY
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: May 22, 2013, 3:44 PM
  2. [CLOSED] Direct Event arguments on server side
    By anup in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 06, 2012, 8:25 PM
  3. [CLOSED] Creating custom control on server side
    By AnulekhaK in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Feb 21, 2012, 10:15 AM
  4. Refresh treepanel from server side after event
    By MikeWallaroo in forum 1.x Help
    Replies: 3
    Last Post: Nov 28, 2011, 9:43 AM
  5. Replies: 2
    Last Post: Mar 08, 2009, 10:11 AM

Posting Permissions