How to get TreePanel selected node from Code Behind?

  1. #1

    How to get TreePanel selected node from Code Behind?

    I search for the discuss, and found the solution as such
    <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>
    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();
            }
    and I used such code in my web application.
    I debug mode,I got nodeStr like this "<nodeID>5</nodeID><text>XXX</text><path>...</path>".
    And so with the code "JSON.Deserialize<Newtonsoft.Json.Linq.JObject>(no deStr); " I got a exception like this "Unexpected character encountered while parsing value:<.Line 1,position 1."
    How can I resolve it?
    Thanks.
    By the way,Why Ext.Net not support GetSelectedNode() fuction directed in the DLL?
  2. #2
    Hmm... Such string (xml represenation) can be if you don't encode extra parametr
    But i see Encode="true" in you code
    Can you create simple example which can be tested locally?
  3. #3
    I got the result.Thank you for your reply.
    In my code I miss the "Encode" paramter.

    But I got the id like "\"5"\",not I wanted "5".
    Last edited by easypower; Oct 10, 2011 at 1:35 AM.

Similar Threads

  1. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  2. Selected Node Id of a TreePanel
    By Z in forum 1.x Help
    Replies: 1
    Last Post: Jul 21, 2010, 8:26 AM
  3. [CLOSED] Get selected node from a TreeGrid or TreePanel from code behind
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 12
    Last Post: Jun 23, 2010, 9:19 AM
  4. Treepanel - Set Selected Node
    By Tbaseflug in forum 1.x Help
    Replies: 2
    Last Post: Dec 01, 2009, 4:46 PM
  5. [CLOSED] TreePanel selected node
    By alainfo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 24, 2009, 6:47 AM

Tags for this Thread

Posting Permissions