PDA

View Full Version : [CLOSED] Loop through fields inside FormPanel in controller



matrixwebtech
Aug 28, 2014, 7:56 AM
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?

Daniil
Aug 28, 2014, 8:15 AM
Hi @matrixwebtech,

It seems you've already asked that before:)
http://forums.ext.net/showthread.php?37371

matrixwebtech
Aug 28, 2014, 8:37 AM
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.

geoffrey.mcgill
Aug 28, 2014, 1:05 PM
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?