[CLOSED] MVC DropDownField Error

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] MVC DropDownField Error

    Hi.

    I'm trying to add DropDownField to my project

    View DropDownField.cshtml
    @{
        ViewBag.Title = "DropDownField";
        var X = Html.X();
    }
    @X.ResourceManager()
    @(
        X.DropDownField()
            .ID("ddfTree")
            .FieldLabel("Tree")
            .Mode(DropDownMode.ValueText)
            .Editable(false)
            .Width(300)
            .Padding(10)
            .TriggerIcon(TriggerIcon.SimpleArrowDown)
            .Component(cp =>
            {
                X.TreePanel()
                    //.Store(
                    //    X.TreeStore()
                    //        .DefaultRootId("_root")
                    //        .Proxy(
                    //            Html.X().AjaxProxy().Url(Url.Action("GetTree"))
                    //        )
                    //)
                    .ID("tpTree")
                    .Height(300)
                    .Shadow(false)
                    .UseArrows(true)
                    .AutoScroll(true)
                    .Header(false)
                    .RootVisible(false)
                    .Root(
                    X.Node().Children(
                        X.Node().Text("To Do").Icon(Icon.Folder).Children(
                            X.Node().Text("Go jogging").Leaf(true).Checked(false),
                            X.Node().Text("Take a nap").Leaf(true).Checked(false),
                            X.Node().Text("Clean house").Leaf(true).Checked(false)
                        ),
    
                        X.Node().Text("Grocery List").Icon(Icon.Folder).Children(
                            X.Node().Text("Bananas").Leaf(true).Checked(false),
                            X.Node().Text("Milk").Leaf(true).Checked(false),
                            X.Node().Text("Cereal").Leaf(true).Checked(false),
                            X.Node().Text("Energy foods").Icon(Icon.Folder).Children(
                                X.Node().Text("Coffee").Leaf(true).Checked(false),
                                X.Node().Text("Red Bull").Leaf(true).Checked(false)
                            )
                        ),
    
                        X.Node().Text("Kitchen Remodel").Icon(Icon.Folder).Children(
                            X.Node().Text("Finish the budget").Leaf(true).Checked(false),
                            X.Node().Text("Call contractors").Leaf(true).Checked(false),
                            X.Node().Text("Choose design").Leaf(true).Checked(false)
                        )
                    )
                ); //TreePanel
            })
            .Listeners(ls =>
            {
                ls.Expand.Handler = "this.component.getRootNode().expand(true);";
                ls.Expand.Single = true;
                ls.Expand.Delay = 100;
            })
    
    )
    Controller DropDownFieldController.cs
    using Ext.Net;
    using Ext.Net.MVC;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    namespace shop.mvc.Controllers
    {
        public class DropDownFieldController : Controller
        {
            //
            // GET: /DropDownField/
            public ActionResult Index()
            {
                return View();
            }
    
            public StoreResult GetTree(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;
                        //asyncNode.Checked = false;
                        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;
                        //treeNode.Checked = false;
                        nodes.Add(treeNode);
                    }
                }
    
                return this.Store(nodes);
            }
        }
    }
    I get following error when I start my sample and trying to dropdown:

    Uncaught TypeError: Cannot call method 'show' of undefined ext.axd?v=10552:18
    Ext.cmd.derive.expand ext.axd?v=10552:18
    Ext.cmd.derive.onTriggerClick ext.axd?v=10552:18
    Ext.form.field.Trigger.override.onTriggerWrapClick ext.axd?v=10552:593
    (anonymous function)
    m ext.axd?v=10552:18

    Ext.Net.Mvc5 v.2.5.2

    Please, can you help me with sample?
    Last edited by Daniil; Jul 02, 2014 at 9:16 AM. Reason: [CLOSED]
  2. #2
    Hi @gimala,

    You should do
    .Component(cp =>
    {
        cp.Add(
            X.TreePanel()
                ...
            )
        ); 
    })
  3. #3
    Thank you very much, Daniil!
    You can close the thread.

Similar Threads

  1. Replies: 5
    Last Post: Mar 28, 2014, 2:45 PM
  2. dropdownfield
    By oet7i in forum 2.x Help
    Replies: 3
    Last Post: Jan 24, 2013, 10:54 PM
  3. Replies: 0
    Last Post: Jan 22, 2013, 3:50 PM
  4. Replies: 9
    Last Post: Jul 18, 2011, 7:55 AM
  5. Replies: 4
    Last Post: Mar 25, 2011, 5:26 AM

Tags for this Thread

Posting Permissions