App.direct undefined

Page 1 of 2 12 LastLast
  1. #1

    App.direct undefined

    Hello
    Please help me. I am trying some basic examples. Here I have a problem with App.direct which is undefined. Here is my code for controller:
    using Ext.Net;
    using Ext.Net.MVC;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace DA.Controllers
    {
        [DirectController(AreaName = "DA", GenerateProxyForOtherControllers = false, IDMode = DirectMethodProxyIDMode.None)]
        public class HomeController : Controller
        {
            // GET: Home
            public ActionResult Index()
            {
                return View();
            }
    
            [DirectMethod]
            public ActionResult NodeLoad(string node)
            {
                NodeCollection nodes = new Ext.Net.NodeCollection();
    
                if (!string.IsNullOrEmpty(node))
                {
                    for (int i = 1; i < 6; i++)
                    {
                        Node asyncNode = new Node();
                        asyncNode.Text = node + i;
                        asyncNode.NodeID = node + i;
                        nodes.Add(asyncNode);
                    }
    
                    for (int i = 6; i < 11; i++)
                    {
                        Node treeNode = new Node();
                        treeNode.Text = node + i;
                        treeNode.NodeID = node + i;
                        treeNode.Leaf = true;
                        nodes.Add(treeNode);
                    }
                }
    
                return this.Direct(nodes);
            }
        }
    }
    and here is a view
    @{
        ViewBag.Title = "Viewport with BorderLayout - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
        var X = Html.X();
    }
    
    @section headtag
    {
        <script>
            var nodeLoad = function (store, operation, options) {
                var node = operation.node;
    
                App.direct.NodeLoad(node.getId(), {
                    success: function (result) {
                        node.set('loading', false);
                        node.set('loaded', true);
                        node.appendChild(result);
                        node.expand();
                    },
    
                    failure: function (errorMsg) {
                        Ext.Msg.alert('Failure', errorMsg);
                    }
                });
    
                return false;
            };
        </script>
    }
    
    @section example
    {
        @(X.Viewport()
            .Layout(LayoutType.Border)
            .Items(
                X.Panel().Title("West").Region(Region.West).Layout(LayoutType.Accordion).Width(225).MinWidth(225).MaxWidth(400).Split(true).Collapsible(true)
                    .Items(
                        X.TreePanel().Title("Navigation").Border(false).BodyPadding(6).Icon(Icon.FolderGo).Root(Html.X().Node().NodeID("0").Text("Root")).Listeners(l => { l.BeforeLoad.Fn = "nodeLoad"; }),
                //X.TreePanel().Title("Navigation").Border(false).BodyPadding(6).Icon(Icon.FolderGo).Root(Html.X().Node().NodeID("0").Text("Root")).DirectEvents(de => { de.BeforeLoad.Url = "Home/Test"; }),
                        X.Panel().Title("Settings").Border(false).BodyPadding(6).Icon(Icon.FolderWrench).Html("Some settings in here")
                    ),
                X.TabPanel().Region(Region.Center).Items(
                        X.Panel()
                            .Title("Main")
                            .Border(false)
                            .BodyPadding(6)
                    )
            )
        )
    }
    I want to mention that part under comment (with "DirectEvents(de => { de.BeforeLoad.Url = "Home/Test"}) is working, only I don't know how to send parameters in that case...
    )
    Also could you tell me where can I find ~/resources/css/examples.css which is refered to in samples
  2. #2
    Hi @ingbabic,

    Welcome to the Ext.NET forums!

    This attribute is supposed to be working only for the Controller which returns the actual View.
    GenerateProxyForOtherControllers = false
    So, please try to remove that.
  3. #3
    Hi Daniil
    Thank you very much for answer. Unfortunately removing
    GenerateProxyForOtherControllers = false
    didn't help. What else could be problem. I want to mention that App object is not undefined or null, only direct.
  4. #4
    Please create a small test project and upload to somewhere that I could download and test.
  5. #5
    actually you can see there two controllers, both of them having same problem (App.direct is not defined). DirectMethod is a sample directly from ext.net samples, and home controller is something I tried to do combining two samples. Thank you very much (zip is big because of packages, I don't know if I should exclude them, project is actually quite small). Thank you very much in advance.
    Last edited by Daniil; Jun 10, 2014 at 4:34 AM. Reason: Removed the link
  6. #6
    No dlls, please. No license keys as well. Could you remove any dlls, license keys if any and re-upload?

    Btw, I am supposed to add only Ext.NET dlls. A test project should not require other dlls.
    Last edited by Daniil; Jun 10, 2014 at 4:38 AM.
  7. #7
    I am sorry but I didn't know how to upload project without packages. Anyway it's not needed at all to upload anything. I'll try to explain it's so simple (I am just a beginner):
    1) Visual Studio 2013 (File->New Project->ASP.NET Web application->Empty template->Checkbox MVC Checked
    2) Right click on project->Manage Nuget Packages->EXT.NET MVC 5->Install->I Accept->Close
    3) Go to Ext.NET sample and download zip. Add Direct_MethodController.cs in Controler folder of app. Right click on Index method->Create View
    4) Copy Index.cshtml from zip to overwrite created index.cs.html in folder Views/Direct_Method. Copy _BaseLayout.cshtml from somewhere in Views/Shared
    5) Start the app and click on plus on root node...

    Hope it's easy. I can send cs an cshtml files but you already have them (I copied them from your site). Thank you very much
    Attached Thumbnails Click image for larger version. 

Name:	1.png 
Views:	32 
Size:	21.6 KB 
ID:	12431   Click image for larger version. 

Name:	2.png 
Views:	31 
Size:	64.9 KB 
ID:	12441   Click image for larger version. 

Name:	3.jpg 
Views:	30 
Size:	93.6 KB 
ID:	12451   Click image for larger version. 

Name:	4.jpg 
Views:	32 
Size:	95.1 KB 
ID:	12461   Click image for larger version. 

Name:	5.jpg 
Views:	45 
Size:	96.5 KB 
ID:	12471  

  8. #8
    Do you use Direct_MethodController.cs without any changes?

    That controller uses AreaName in DirectController attribute (on your screenshot i don't see any areas in your app)
    Also that controller generates direct method proxy for views from this controller only (due GenerateProxyForOtherControllers = false)

    So, remove AreaName if you don't use areas and remove GenerateProxyForOtherControllers if you need to generate proxy for another controller views
  9. #9
    Cool, that was that! Could you please explain me for what areas are used? What is benefit of using them? Thank you.
  10. #10
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: May 13, 2014, 8:52 AM
  2. [CLOSED] App.direct is undefined
    By jesperhp in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Dec 04, 2013, 12:53 PM
  3. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  4. Direct method and direct event over SSL?
    By dimitar in forum 1.x Help
    Replies: 0
    Last Post: Oct 08, 2011, 8:09 PM
  5. Replies: 3
    Last Post: Apr 20, 2010, 12:21 PM

Tags for this Thread

Posting Permissions