[CLOSED] Loop through fields inside FormPanel in controller

  1. #1

    [CLOSED] Loop through fields inside FormPanel in controller

    I have a design like bellow

    @(X.FormPanel().Layout(LayoutType.HBox).ID("f").Layout(LayoutType.VBox)
    .Items
    (
     X.TextField()
     .ID("f1")
     .FieldLabel("f1")
    
     ,
    
     X.NumberField()
     .ID("f2")
     .FieldLabel("f2")
     , X.NumberField()
     .ID("f3")
     .FieldLabel("f3")
      ,
    
     X.NumberField()
     .ID("f4")
     .FieldLabel("f4")
        // ,
          
    
    )
    )
    I want to get all fields inside frompanel and loop through,but

    public ActionResult Index()
            {
                var f = X.GetCmp<FormPanel>("f").Items;
                return View();
            }
    but f count is always 0.

    how do I do this?
    Last edited by matrixwebtech; Nov 05, 2014 at 12:07 PM.
  2. #2
    Hi @matrixwebtech,

    It seems you've already asked that before:)
    http://forums.ext.net/showthread.php?37371
  3. #3
    apologies for this post.

    I try with

    public class DynamicFieldController : Controller
        {
            //
            // GET: /DynamicField/
    
            public ActionResult Index()
            {
                List<set> o = new List<set>();
                for (int i = 1; i <= 4; i++)
                {
                    var anonymousObject = new set();
                    anonymousObject.id = "f" + i.ToString();
                    anonymousObject.visible = true;
                    anonymousObject.extra =  i.ToString();
                    o.Add(anonymousObject);
                }
                ViewBag.set = o;
    
                return View();
            }
    
        }
    
        public class set
        {
            public string id { get; set; }
            public bool visible { get; set; }
            public string extra { get; set; }
        }

    @using Ext.Net
    @using Ext.Net.MVC
    @using System.Collections;
    
    @{
        Layout = null;
        var X = Html.X();
    
        List<e.Controllers.set> _set = ViewBag.set;
      
    }
    
    <script>
    
        Ext.onReady(function () {
        @foreach (var r in _set)
       {
           @:Ext.getCmp('@r.id').setVisible(@r.visible)
       }
        })
    
    </script>
    
    
    @X.ResourceManager()
    
    
    @(X.FormPanel().Layout(LayoutType.HBox).ID("f").Layout(LayoutType.VBox)
    .Items
    (
     X.TextField()
     .ID("f1")
     .FieldLabel("f1")
    
     ,
    
     X.NumberField()
     .ID("f2")
     .FieldLabel("f2")
     , X.NumberField()
     .ID("f3")
     .FieldLabel("f3")
      ,
    
     X.NumberField()
     .ID("f4")
     .FieldLabel("f4")
        // ,
          
    
    )
    )
    ReferenceError: True is not defined
    	
    Ext.getCmp('f1').setVisible(True)



    but there are a javascript error,I found in fire bug.can you please check.
    Last edited by matrixwebtech; Nov 05, 2014 at 12:07 PM.
  4. #4
    but there are a javascript error,I found in fire bug.can you please check.
    It would be best if you checked. The JavaScript error message is pretty obvious.

    ReferenceError: True is not defined
    When you googled that error message, what did the results suggest as a solution? Are you sure this error message has something to do with Ext.NET?
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Loop through Fields iside form panel
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 14, 2014, 4:43 AM
  2. [CLOSED] Removing Checkboxes / Radiobuttons from Frompanel
    By extnetuser in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 27, 2013, 3:55 PM
  3. [CLOSED] Apply DefaultButton to the FromPanel in codebehind
    By ViDom in forum 2.x Legacy Premium Help
    Replies: 0
    Last Post: May 14, 2013, 8:24 AM
  4. [CLOSED] GridPanel built inside Controller does not show records
    By AlbertoCe in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 05, 2013, 8:06 PM
  5. Replies: 0
    Last Post: Jul 09, 2010, 4:19 PM

Posting Permissions