Please investigate with the code below. We cannot get the data binded to the corresponding column. Please use the Ext.net v2.1.1 to test. We cannot move to v2.2.0 for it will break other parts of our code.
// Controller Code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using Ext.Net.MVC.Sample.Models;
using Ext.Net.MVC.Sample.Models.Remote;
using Ext.Net.MVC.Sample.Utilities;
namespace Ext.Net.MVC.Sample.Controllers
{
[HandleError]
[DirectController]
public class OrdersSummaryController : Controller
{
//
// GET: /OrdersSummary/
public ActionResult Index()
{
return View();
}
[DirectMethod]
public DirectResult ReBuildOrderSummaryTree()
{
NodeCollection nodes = BuildTree2(null);
return this.Direct(nodes.ToJson());
}
private NodeCollection BuildTree2(NodeCollection nodes)
{
if (nodes == null)
{
nodes = new NodeCollection();
}
var root = new Node();
root.Text = "Root";
root.NodeID = "Root";
root.Expanded = true;
nodes.Add(root);
var node = new Node
{
NodeID = "USTP",
Leaf = false,
Icon = Icon.Folder,
/*CustomAttributes =
{
new ConfigItem("Region", "USTP"),
new ConfigItem("FlowType", "ALGO"),
new ConfigItem("Moniker", "WA"),
new ConfigItem("BusUnit", "USTP"),
new ConfigItem("Shares", "999"),
new ConfigItem("OrdersCount", "1000")
},*/
AttributesObject = new { region = "USTP", flowType = "ALGO",
moniker = "WA", busUnit = "USTP", shares = 999, ordersCount = 1000},
Expandable = false, EmptyChildren = true
};
root.Children.Add(node);
return nodes;
}
}
}
@model dynamic
@Html.X().ResourceManager()
@{
ViewBag.Title = "Orders Summary";
Layout = null;
BuilderFactory<dynamic> X = Html.X();
<script>
var OnSelectionChange = function(selModel, node) {
};
var refreshTree = function () {
Ext.getBody().mask('Loading Order Summary...', 'x-mask-loading');
App.direct.ReBuildOrderSummaryTree({
success: function (result) {
var nodes = eval(result);
if (nodes.length > 0) {
App.TreePanel1.setRootNode(nodes[0]);
} else {
App.TreePanel1.getRootNode().removeAll();
}
Ext.net.Mask.hide();
},
failure: function (result) { Ext.net.Mask.hide(); }
});
}
</script>
<style>
.x-grid-custom .x-grid-row TD { font: 12px/16px "segoe ui", arial, sans-serif; }
.x-grid-custom .x-column-header {
background: #718CA1 url(../../header_sprite.png) repeat scroll 0 bottom;
border-left-color: #6085A5;
border-right-color: #728BA1;
font: 12px/16px "segoe ui", arial, sans-serif;
height: 22px;
}
.x-grid-custom .x-column-header-over { background: #65a3f1 url(../../header_sprite_over.png) repeat 0 bottom !important; }
.x-grid-custom .x-column-header div { color: white; }
.x-grid-custom .company-link { color: #0E3D4F; }
.x-grid-custom .x-column-header-trigger { background: #718CA1 url(../../grid3-hd-btn.png) no-repeat left center; }
.x-grid-custom .x-grid-row-alt .x-grid-cell { background-color: #DAE2E8; }
.x-grid-custom .x-grid-row-over .x-grid-cell {
background: url(../../row-over.png);
border-color: #728BA1;
}
.x-grid-custom .x-grid-row-selected .x-grid-cell {
background: url(../../row-selected.png) repeat-x scroll 0 0 #7BBBCF;
border-color: #728BA1;
border-style: solid;
}
.x-grid-custom .x-grid-row-selected TD,
.x-grid-custom .x-grid-row-selected TD .company-link { color: #fff; }
.x-grid-custom .x-toolbar .x-toolbar-text { color: #fff !important; }
.x-grid-custom .x-toolbar { background: url(../../toolbar-bg.png) repeat-x 0 0 !important; }
.x-grid-custom .x-tbar-loading { background-image: url(../../refresh.gif) !important; }
.x-grid-custom .x-tbar-page-first { background-image: url(../../page-first.gif) !important; }
.x-grid-custom .x-tbar-page-last { background-image: url(../../page-last.gif) !important; }
.x-grid-custom .x-tbar-page-next { background-image: url(../../page-next.gif) !important; }
.x-grid-custom .x-tbar-page-prev { background-image: url(../../page-prev.gif) !important; }
.x-grid-custom .x-paging-info { color: #fff; }
</style>
}
<!DOCTYPE html>
<html>
<head>
<title>title</title>
</head>
<body>
@(X.TreePanel().Title("Orders Summary").ID("TreePanel1").NoLeafIcon(false)
.Animate(true).Cls("x-grid-custom")
// .Width(500)
.Height(900)
.Collapsible(true)
.UseArrows(true)
.RootVisible(false)
.MultiSelect(true)
.SingleExpand(false)
.FolderSort(true)
.Fields(
X.ModelField().Name("busUnit"),
X.ModelField().Name("shares").Type(ModelFieldType.Int),
X.ModelField().Name("ordersCount").Type(ModelFieldType.Int),
X.ModelField().Name("notional").Type(ModelFieldType.Float)
)
.ColumnModel(
X.TreeColumn()
.Text("Business Unit")
.Flex(1)
.DataIndex("busUnit"),
X.NumberColumn()
.Text("Shares")
.Flex(1)
.DataIndex("shares")
.Align(Alignment.Right)
.Format("0,000."),
//.Align(Alignment.Center),
X.NumberColumn()
.Text("Orders Count")
.Flex(1)
.DataIndex("ordersCount")
.Align(Alignment.Right)
.Format("0,000.")
)
.SelectionModel(Html.X().TreeSelectionModel()
.Mode(SelectionMode.Single)
.Listeners(ls => ls.SelectionChange.Fn = "OnSelectionChange")
)
.Tools(Html.X().Tool().Type(ToolType.Refresh)
.Handler("refreshTree();")
.ToolTips(tts => tts.Add(Html.X().ToolTip().ID("ToolTip1").Html("Refresh"))
)
)
.Root(
X.Node().Text("Business Units")
.EmptyChildren(true)
)
)
</body>
</html>