How to handle treepanel clicked node details(id,text,tag,or as Ext.Net.Node object) at server-side ?

  1. #1

    How to handle treepanel clicked node details(id,text,tag,or as Ext.Net.Node object) at server-side ?

    I have tried below code.
    I'm using that release https://www.nuget.org/packages/Ext.NET.MVC/3.2.0

    TreePanel treePanel = new TreePanel();
    treePanel.ID = "TreePanel1";
    treePanel.RootVisible = false;
    
    treePanel.DirectEvents.ItemClick.Url = "/Menu/TreePanelClickHandler";
    treePanel.DirectEvents.ItemClick.Method = HttpMethod.POST;
    treePanel.DirectEvents.ItemClick.ExtraParams.Add(new Parameter("param1", "value1", ParameterMode.Value));
    treePanel.DirectEvents.ItemClick.ExtraParams.Add(new Parameter("param2", "value2", ParameterMode.Value));

    public class MenuController : Controller
    {
       public ActionResult TreePanelClickHandler(string param1,string param2)
       {
          X.Msg.Alert("server-side:", param1 + "\n" + param2).Show();
          AjaxResult r = new AjaxResult();
          return r;
       }
    }
    any idea ?
    Last edited by ismailkocacan; Aug 10, 2015 at 1:11 PM.
  2. #2
    I have changed below code lines.

    treePanel.DirectEvents.ItemClick.Url = "/Menu/TreePanelClickHandler";
    treePanel.DirectEvents.ItemClick.Method = HttpMethod.POST;
    treePanel.DirectEvents.ItemClick.ExtraParams.Add(new Parameter("param1", "value1", ParameterMode.Value));
    treePanel.DirectEvents.ItemClick.ExtraParams.Add(new Parameter("param2", "value2", ParameterMode.Value));
    to

    treePanel.DirectEvents.ItemClick.Before = "o.extraParams.param1 = record.data.id; o.extraParams.param2 = record.data.text;";
    treePanel.DirectEvents.ItemClick.Url = "/Menu/TreePanelClickHandler";
    treePanel.DirectEvents.ItemClick.Method = HttpMethod.POST;

    it works very well. :)


    My another question;
    How to pass Ext.Net.Node other properties as parameter?
  3. #3
    OK. I have solved problem.

    changed to

    treePanel.DirectEvents.ItemClick.Before = "o.extraParams.param1 = record.data.id; o.extraParams.param2 = record.data.text; o.extraParams.param3 = record.raw['tag'];";
    treePanel.DirectEvents.ItemClick.Url = "/Menu/ClickMeHandler";
     treePanel.DirectEvents.ItemClick.Method = HttpMethod.POST;

    when Ext.Net.Node creating
    subNode.CustomAttributes.Add(new ConfigItem("tag", "testdata"));

    public class MenuController : Controller
    {
       public ActionResult TreePanelClickHandler(string param1,string param2,string param3)
       {
          X.Msg.Alert("server-side:", param1 + "\n" + param2+ "\n" + param3).Show();
          AjaxResult r = new AjaxResult();
          return r;
       }
    }

Similar Threads

  1. [CLOSED] TreePanel selected node (Server Side)
    By cwolcott in forum 2.x Premium Help
    Replies: 1
    Last Post: Dec 07, 2012, 11:23 PM
  2. Replies: 3
    Last Post: Nov 13, 2012, 3:17 PM
  3. [CLOSED] Treepanel selected node server side
    By alainfo in forum 1.x Premium Help
    Replies: 5
    Last Post: Jun 09, 2011, 1:49 PM
  4. Replies: 3
    Last Post: May 25, 2010, 4:29 PM
  5. add node dynamic on server side
    By simbal in forum 1.x Help
    Replies: 1
    Last Post: Apr 27, 2009, 5:44 PM

Posting Permissions