TreePanel, get selected node

  1. #1

    TreePanel, get selected node

    var treePanel = X.TreePanel()
    
     treePanel.DirectEvents(ev =>
            {
                ev.ItemClick.Url = Url.Action("AddMasterDetailTab");
                ev.ItemClick.ExtraParams.Add(new { containerId = "Tabs", Title = ????});
            });
    How do I add the node title to the ???? space?
    Thanks
  2. #2
    Try this
    Title = JRawValue.From("record.data.text")
  3. #3
    Hi,
    Thank you.
    Can you please explain why this is not possible, is it because the url coming static from the server?
     treePanel.DirectEvents(ev =>
        {
            ev.ItemClick.Url = Url.Action("AddMasterDetailTab", JRawValue.From("record.data.id"));
            ev.ItemClick.ExtraParams.Add(
                new
                {
                    containerId = "Tabs"
                    , title = JRawValue.From("record.data.text")
                });
    
        });
    instead of getting the real ID I am getting the string: record.data.id

    I want to have a tree node panel that is the main menu of the app.
    On click on the node I want to get its ID and load a tab(where the node id is the controller name).
    Is it possible to do like I tried to?

    Thanks
  4. #4
    Try this
    ev.ItemClick.Before = "o.url = '/AddMasterDetailTab/' + record.data.id;";
  5. #5
    Hi.
    Thanks.
    this does nothing:

    treePanel.DirectEvents(ev =>
        {
            ev.ItemClick.Before = "o.url = '/AddMasterDetailTab/' + record.data.id;";
            ev.ItemClick.ExtraParams.Add(
                new
                {
                    
                    containerId = "Tabs"
                    , title = JRawValue.From("record.data.text")
                    , model = JRawValue.From("record.data.id")
                });
        });
    and also this:
    ev.ItemClick.Before = "alert(record.data.id)";
    Thanks
  6. #6
    You need to set default url otherwise direct event will not be rendered
         ev.ItemClick.Url = "DefaultUrl";
  7. #7
    Thanks, that worked,

    1. Can you please tell me why is the default url needed? what does it do?

    2. And how can I prevent reopen the same tab again when clicking on it?

    @(Html.X().Panel()
    .Title(ViewData["title"].ToString())
    .Closable(true)
    .Layout(LayoutType.Fit)
    .Items(....));

    Thanks!
  8. #8
    @Vladimir Can you please respond my last question.
    Thanks for your time

Similar Threads

  1. Replies: 4
    Last Post: Mar 22, 2015, 4:04 PM
  2. Replies: 11
    Last Post: Feb 06, 2013, 5:09 PM
  3. Selected Node Id of a TreePanel
    By Z in forum 1.x Help
    Replies: 1
    Last Post: Jul 21, 2010, 8:26 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