[CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    I have a DirectEvent Click handler on a tree, and I would like to get the selected node and it's config items from the code behind.

    Can you give me an example of this?
  2. #2

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Also, what's the best way to get a configitem from the node's customattributes? do i have to iterate through them and check the name against what I want?
  3. #3

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Any ideas? I'm kind of in a time crunch. :(
  4. #4

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Hi,

    Sorry for the late response

    1. Button to submit a node
    <ext:Button runat="server" Text="Submit selected node">
                        <DirectEvents>
                            <Click OnEvent="SubmitNode">
                                <ExtraParams>
                                    <ext:Parameter Name="node" Value="#{TreeGrid1}.convertToSubmitNode(#{TreeGrid1}.getSelectionModel().getSelectedNode())" Mode="Raw" Encode="true"/>
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </ext:Button>
    2. Server handler
     protected void SubmitNode(object sender, DirectEventArgs e)
            {
                string nodeStr = e.ExtraParams["node"];
                Newtonsoft.Json.Linq.JObject node = JSON.Deserialize<Newtonsoft.Json.Linq.JObject>(nodeStr);
                string id = node.Property("nodeID").Value.ToString();
                string path = node.Property("path").Value.ToString();
                string task = node.SelectToken("attributes.task").ToString();
            }
  5. #5

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    If I'm using a TreeGrid, how would I get the value of the ConfigItem named "whatever" from the node's CustomAttributes?
  6. #6

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Or is that what this part does?

    string task = node.SelectToken("attributes.task").ToString()
  7. #7

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Hi,

    If I'm using a TreeGrid, how would I get the value of the ConfigItem named "whatever" from the node's CustomAttributes?
    Please use
    string whatever= node.SelectToken("attributes.whatever").ToString();
  8. #8

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    I'm trying to set a custom attribute on a node:

    n.CustomAttributes.Add(New Ext.Net.ConfigItem("type", "account", ParameterMode.Value))

    But when I retrieve the value from the node after deserializing it (using the example above), the value is ""account"". It's like it's quoted twice.


    Also, when trying to retrieve my other attribute:


    n.CustomAttributes.Add(New Ext.Net.ConfigItem("id", CStr(a.AccountID), ParameterMode.Value))

    I get a "Object reference not set to an instance of an object." javascript error.


    What am I doing wrong?
  9. #9

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    Actually, I should clarify. The one that's getting double quoted is defined like:

    n.CustomAttributes.Add(New Ext.Net.ConfigItem("type", "'account'", ParameterMode.Value))

    When I defined it without the single quotes, the browser complained that there was no property named "account".
  10. #10

    RE: [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind

    This was the only way I was able to get it to work:

    Setting:


    n.CustomAttributes.Add(New Ext.Net.ConfigItem("objectid", CStr(a.AccountID), ParameterMode.Value))

    Getting:


    Dim id = CInt(node.SelectToken("attributes.objectid").ToString.Trim(""""))


    Something about having to strip the quotes out just seems wrong. Is this the only way?
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: Oct 10, 2011, 1:29 AM
  2. [CLOSED] Get selected node in javascript (Treegrid)
    By fordprefect in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 01, 2011, 4:00 PM
  3. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  4. [CLOSED] Retrieve the selected row or node from a treeGrid
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 17, 2010, 7:51 PM
  5. Treepanel - Set Selected Node
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: Dec 01, 2009, 4:46 PM

Posting Permissions