[CLOSED] Treegrid nodes

  1. #1

    [CLOSED] Treegrid nodes

    Hi,

    I've some problems using the treegrid. If the grid load data using the model the nodes description are empty.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	164 
Size:	3.9 KB 
ID:	5175

    This is the controller action I use to render the view :

        public ActionResult Index()
        {
          NodeCollection nodes = new Ext.Net.NodeCollection();
    
          nodes.AddRange( new [] { new Node()
          {
            Text = "1",
            NodeID = "1",
            Leaf = true,
            AttributesObject = new
            {
              Code = "1Code",
              Description = "1Description",
              CreationDate = "1CreationDate",
              LastUpdateDate = "1LastUpdateDate"
            }
          },
          new Node()
          {
            Text = "2",
            NodeID = "2",
            Leaf = true, //c.Children.Any(),
            AttributesObject = new
            {
              Code = "2Code",
              Description = "2Description",
              CreationDate = "2CreationDate",
              LastUpdateDate = "2LastUpdateDate"
            }
          }      
          });
    
          return View(nodes);
        }
    This is the view :

    @model Ext.Net.NodeCollection
    @(
     Html.X().Viewport()
      .Layout(LayoutType.Border)
      .Split(true)
      .Items(vpItems =>
      {
        vpItems.Add(
              Html.X().TreePanel()
                .Height(300)
                .Split(true)
                .AnimCollapse(true)
                .Collapsible(true)
                .Region(Region.Center)
                .UseArrows(true)
                .RootVisible(false)
                .Fields(
                  Html.X().ModelField().Name("Description")
                )
                .ColumnModel(
                  Html.X().TreeColumn().DataIndex("Description").Text("description")
                )
                .Root(Html.X().Node().NodeID("0").Text("description").Children(Model))
         );
    
     })
    )
    What should I change to make it work ?

    Regards,
    Alberto
    Last edited by Daniil; Nov 28, 2012 at 3:03 PM. Reason: [CLOSED]
  2. #2
    Hello!

    By default, all AttributesObject serializing to objects where name of fields starts with lowercase letter even.

    @(
     Html.X().Viewport()
      .Layout(LayoutType.Border)
      .Split(true)
      .Items(vpItems => vpItems.Add(
        Html.X().TreePanel()
    		.Height(300)
    		.Split(true)
    		.AnimCollapse(true)
    		.Collapsible(true)
    		.Region(Region.Center)
    		.UseArrows(true)
    		.RootVisible(false)
    		.Fields(
                Html.X().ModelField().Name("description")
    		)
    		.ColumnModel(
                Html.X().TreeColumn().DataIndex("description").Text("description")
    		)
            .Root(Html.X().Node().NodeID("0").Text("description").Children(Model))
      	)
      )
    )
  3. #3
    Hello,

    Renaming the AttributesObject properties to lowercase works !

    Thank you very much.

    Alberto.
  4. #4
    Hi,

    Just to clarify: it is done to meet JavaScript naming convention, i.e. lowercase first letter of properties.

Similar Threads

  1. [CLOSED] TreeGrid doesn't display nodes
    By agonzalez in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Oct 05, 2012, 12:01 PM
  2. Custom TreeGrid nodes ?
    By Mohammad in forum 1.x Help
    Replies: 18
    Last Post: Aug 22, 2012, 9:49 AM
  3. Replies: 7
    Last Post: Oct 06, 2010, 6:44 PM
  4. [CLOSED] TreeGrid example on examples.ext.net does not show any nodes
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 24, 2010, 4:44 PM
  5. [CLOSED] [1.0] Setting Cls property on nodes with TreeGrid
    By tdracz in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2010, 1:23 PM

Tags for this Thread

Posting Permissions