Mvc - TreePanel click on Node

  1. #1

    Mvc - TreePanel click on Node

    Hi everyone ,
    i got a TreePanel with a few nodes. I'd like to add a Direct Method or sth like that on every single node, so that i can call a method
    on the Controller with the oid of the node as parameter. I already tried with a Listener (not the one posted for the filter) but that didn't work for me.

    @section example
    {
        @(X.TreePanel()
              .Width(200)
              .Height(400)
              .Title("Foldercontent")
              .Icon(Icon.ChartOrganisation)
            .TopBarItem(
                Html.X().ToolbarTextItem().Text("Filter:"),
                Html.X().ToolbarSpacer(),
                Html.X().TriggerField()
                    .EnableKeyEvents(true)
                    .Triggers(
                        Html.X().FieldTrigger().Icon(TriggerIcon.Clear)
                    )
                    .Listeners(l =>
                    {
                        l.KeyUp.Fn = "filterTree";
                        l.KeyUp.Buffer = 250;
    
                        l.TriggerClick.Fn = "clearFilter";
                    })
                    )
                .Fields(
                X.ModelField().Name("oid"),
                X.ModelField().Name("dirname")
                 )
               .RootVisible(true)
               .Root(Model)
        )
    }
    best regards.
    Last edited by novacp; Feb 11, 2014 at 6:09 AM.
  2. #2
    In addition:

    i got this in my @headtag script block:

    var nodeLoad = function () {
                alert("clicked");
            }
    and added this to my treepanel:

    .Listeners(l =>
                {
                    l.ItemClick.Handler = "nodeLoad()";
                })
    the alert works.
    but how can i now call a method from the controller with the node id as param?

    Update:

    i tried it with:
      .Listeners(l =>
                {
                    l.ItemClick.Fn = "nodeLoad";
                })
    and in script tag:
    var nodeLoad = function (store, operation, options) {
                alert(operation.node.getId());
            };
    can't access the id of the node to call after that App.direct.NodeLoad(node.getId(), {...
    Last edited by novacp; Feb 11, 2014 at 7:40 AM.
  3. #3
    ok guys got the path of the clicked node in my function with record:
    var nodeLoad = function (view, record, item, index, event) {
    How is it now possible to call the DirectMethod of my Controller ?

    script now looks like:
     App.direct.CreateGridPanel(path, {
                    success: function (result) {
                        alert(result);
                    },
    
                    failure: function (errorMsg) {
                        Ext.Msg.alert('Failure', errorMsg);
                    }
                });
    Method in Controller:

    [DirectMethod]
            public string CreateGridPanel(string path)
            {
                return "yes";
            }
    error msg:
    ReferenceError: App is not defined


    App.direct.Events.CreateGridPanel(path, {
    Regards
    Last edited by novacp; Feb 11, 2014 at 8:25 AM.
  4. #4
    already a lot of views and nobody knows why this is not working for me?
    var nodeLoad = function (view, record, item, index, event) {
                var nodeId = record.data.id;
                var path = record.getPath('text', '/');
                
                App.direct.CreateGridPanel(path, {
                    success: function (result) {
                        alert(result);
                    },
    
                    failure: function (errorMsg) {
                        alert(errorMsg);
                    }
                });
            };
    "App not known"..

Similar Threads

  1. Treepanel - Expand Node on Single Click - How to?
    By Tbaseflug in forum 2.x Help
    Replies: 1
    Last Post: Dec 12, 2012, 11:31 AM
  2. [CLOSED] [1.0] Treepanel click node problem with ie9
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 13, 2012, 12:44 PM
  3. No Expanded on click treepanel node!
    By abis in forum 2.x Help
    Replies: 2
    Last Post: Aug 12, 2012, 5:22 AM
  4. [CLOSED] Select node on Treepanel with right click...
    By tjbishop in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Sep 13, 2010, 10:33 PM
  5. Right-click node select in TreePanel?
    By dbassett74 in forum 1.x Help
    Replies: 6
    Last Post: May 14, 2009, 12:17 PM

Tags for this Thread

Posting Permissions