Dec 11, 2015, 8:44 AM
[CLOSED] GridPanel with Dynamic Fields and Columns
Hi
I'm trying to develop a GridPanel where the number of model fields and grid columns varies according to the data settings. I've developed a simple example adding a model field and a column but I can't seem to make it work. I've seen examples based on Web Forms but I can't find any help for MVC.
This is the View:
I'm trying to develop a GridPanel where the number of model fields and grid columns varies according to the data settings. I've developed a simple example adding a model field and a column but I can't seem to make it work. I've seen examples based on Web Forms but I can't find any help for MVC.
This is the View:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script>
</script>
</head>
<body>
@Html.X().ResourceManager().ScriptMode(Ext.Net.ScriptMode.Debug).SourceFormatting(true)
@(Html.X().GridPanel().Width(352)
.Title("Users").ID("GridPanel").Border(true)
.Store(Html.X().Store()
.ID("Store")
.Model(Html.X().Model().ID("Model").IDProperty("ID")
.Fields(
new ModelField("ID", ModelFieldType.Int)
)
)
.Proxy(Html.X().AjaxProxy().Url(Url.Action("Read")).Reader(Html.X().JsonReader().RootProperty("data"))))
.ColumnModel(
)
)
</body>
</html>
This is the Controller:using Ext.Net;
using Ext.Net.MVC;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
namespace ExtNetBugsMVC.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult Read()
{
List<User> lstUsers = new List<User>();
lstUsers.Add(new User(1000, "Jeff"));
lstUsers.Add(new User(1001, "James"));
X.GetCmp<Model>("Model").Fields.Add(new ModelField("Name"));
X.GetCmp<GridPanel>("GridPanel").ColumnModel.Columns.Add(new Column { DataIndex = "Name", Text = "Name" });
X.GetCmp<GridPanel>("GridPanel").Reconfigure();
return this.Store(lstUsers);
}
}
public class User
{
public User()
{
}
public User(int id, string name)
{
ID = id;
Name = name;
}
public int ID { get; set; }
public string Name { get; set; }
}
}
Last edited by fabricio.murta; Dec 31, 2015 at 12:58 PM.
Reason: [CLOSED]