No problem, Please find attached code for the issue.
Thanks
szhang
//index.cshtml
@using Ext.Net;
@using Ext.Net.MVC;
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Ext.NET MVC Sample</title>
<link type="text/css" rel="stylesheet" href="http://speed.ext.net/www/intro/css/main.css" />
</head>
<body>
@(Html.X().ResourceManager())
<header>
<a href="http://ext.net/"><img src="http://speed.ext.net/identity/extnet-logo-large.png" class="logo"/></a>
</header>
@(
Html.X().Window()
.Icon(Icon.Table)
.Width(740)
.Height(600)
.Layout(LayoutType.Fit)
.Title("Grid Window")
.TopBarItem(
Html.X().Button()
.Text("reconfig")
.Icon(Icon.Add)
.Handler ("RefreshColumns()")
)
.Items(
Html.X().GridPanel().ID("Grid1")
.Frame(true)
.Store(
Html.X().Store()
.RemotePaging(false)
.AutoLoad(true)
.Proxy(
Html.X().AjaxProxy()
.Url(Url.Action("LoadDynamicGridData", "ExtNet"))
.Reader(Html.X().JsonReader().RootProperty("data").MessageProperty("message"))
)
.PageSize(10)
.Model(Html.X().Model()
.Fields(
new ModelField("company"),
new ModelField("price", ModelFieldType.Float),
new ModelField("change", ModelFieldType.Float),
new ModelField("pctChange", ModelFieldType.Float),
new ModelField("lastChange", ModelFieldType.Date, "M/d hh:mmtt")
)
)
)
.ColumnModel(
Html.X().Column().Text("Company").DataIndex("company").Locked(true),
Html.X().Column().Text("Price").DataIndex("price").Renderer(RendererFormat.UsMoney),
Html.X().Column().Text("Change").DataIndex("change").Renderer("change"),
Html.X().Column().Text("pctChange").DataIndex("pctChange"),
Html.X().Column().Text("lastChange").DataIndex("lastchange")
)
.SelectionModel( Html.X().SpreadsheetSelectionModel().ID("selModel1").RowSelect(true))
.View( Html.X().GridView().StripeRows(true) )
.Features (
Html.X().GroupingSummary()
.GroupHeaderTplString("{columnName}: {name} ({[values.rows.length]} {[values.rows.length > 1 ? \"Items\" : \"Item\"]})")
.HideGroupedHeader(true)
.ShowSummaryRow(true)
.StartCollapsed(true)
)
.Plugins(Html.X().CellEditing())
.BottomBar( Html.X().PagingToolbar())
)
)
<script>
var template = '<span style="color:{0};">{1}</span>';
var change = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value);
};
var pctChange = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
};
var RefreshColumns = function () {
Ext.net.DirectMethod.request({
url: '/ExtNet/RefreshColumns',
success: function (result) {
Ext.Msg.alert("Msg", "columns refreshed");
},
failure: function (result) {
Ext.Msg.alert("Error", result);
}
});
};
</script>
</body>
</html>
//ExtNetController.cs
using System.Web.Mvc;
using System.Collections.Generic;
using Ext.Net;
using Ext.Net.MVC;
using ExtMVC4._1.Models;
namespace ExtMVC4._1.Controllers
{
public class ExtNetController : Controller
{
public ActionResult Index()
{
ExtNetModel model = new ExtNetModel()
{
Title = "Welcome to Ext.NET",
TextAreaEmptyText = ">> Enter a Message Here <<"
};
return this.View(model);
}
public ActionResult LoadDynamicGridData(string action, Dictionary<string, object> extraParams)
{
var data = new List<object>
{
new { company = "3m Co", price = 71.72, change = 0.02, pctChange = 0.03, lastChange = "9/1 12:00am" },
new { company = "Alcoa Inc", price = 29.01, change = 0.42, pctChange = 1.47, lastChange = "9/1 12:00am" },
new { company = "Altria Group Inc", price = 83.81, change = 0.28, pctChange = 0.34, lastChange = "9/1 12:00am" },
new { company = "American Express Company", price = 52.55, change = 0.01, pctChange = 0.02, lastChange = "9/1 12:00am" },
new { company = "American International Group, Inc.", price = 64.13, change = 0.31, pctChange = 0.49, lastChange = "9/1 12:00am" },
new { company = "AT&T Inc.", price = 31.61, change = -0.48, pctChange = -1.54, lastChange = "9/1 12:00am" },
new { company = "3m Co 1", price = 71.72, change = 0.02, pctChange = 0.03, lastChange = "9/1 12:00am" },
new { company = "Alcoa Inc 1", price = 29.01, change = 0.42, pctChange = 1.47, lastChange = "9/1 12:00am" },
new { company = "Altria Group Inc 1", price = 83.81, change = 0.28, pctChange = 0.34, lastChange = "9/1 12:00am" },
new { company = "American Express Company 1", price = 52.55, change = 0.01, pctChange = 0.02, lastChange = "9/1 12:00am" },
new { company = "American International Group, Inc. 1", price = 64.13, change = 0.31, pctChange = 0.49, lastChange = "9/1 12:00am" },
new { company = "AT&T Inc. 1", price = 31.61, change = -0.48, pctChange = -1.54, lastChange = "9/1 12:00am" },
new { company = "Wal-Mart Stores, Inc.", price = 45.45, change = 0.73, pctChange = 1.63, lastChange = "9/1 12:00am" }
};
return this.Store(data);
}
}
}