PDA

View Full Version : [CLOSED] PartialViewResult broken for v2.2.0



gets_gui
Mar 18, 2013, 2:10 PM
Hi,

I have a quick question in using PartialViewResult. I have a view which has multiple tab in it and it would be added to the tabpanel using a PartialViewResult. However, when I use the latest version of ext.net 2.2.0 from the trunk (3/18/2013). It is failing and the view only show the tab but the content did not render (ie. empty). Can you suggest way of solving it? I know you would say to submit an example. But, when I tried the same case it would work on ext.net v2.1.0.

Thanks.

Vladimir
Mar 18, 2013, 2:30 PM
I cannot reproduce the issue with examples from MVC Examples Explorer
Please post your test case

gets_gui
Mar 18, 2013, 4:01 PM
I search the logfile for version 2.2.0, and I found that there is a bug fix:

[r4585] PartialViewResult generate incorrect script for Items mode

However, when I tried this, and it doesn't seem to fix the problem. Yet, if I revert to the v2.1.1, it seems that the CustomAttributes on the TreeNode is not being serialized. (which I think has been fixed in v2.2.0).

My question is that what has been fixed in PartialViewResult for generating correct script? Any workaround if I want to stick with v 2.1.1 if I would like the custom attributes being serialized? (I build the Tree Panel in the controller and set the root node on the client side.



I cannot reproduce the issue with examples from MVC Examples Explorer
Please post your test case

Vladimir
Mar 18, 2013, 4:12 PM
Yet, if I revert to the v2.1.1, it seems that the CustomAttributes on the TreeNode is not being serialized.

Online examples explorer uses Ext.Net 2.1.1 and CustomAttributes works fine
http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/



My question is that what has been fixed in PartialViewResult for generating correct script?

All code changes you can view in Show Log dialog of TortoiseSVN client for revision 4585

Why don't you want to post a sample reproduces the PartialViewResult issue?

gets_gui
Mar 18, 2013, 4:34 PM
The problem is that when you serialized the nodes to its Json string and bind it the the javascript side, the Custom Attributes are not being serialized. The online example is to build a static tree. We need to build a dynamic tree on the C# side and be able to bind the custom attributes on the client side on demand. Is there any way you can come up an example of how to do it on Ext.net v2.1.1 which is the latest stable version?

Thanks a lot for your help.


Online examples explorer uses Ext.Net 2.1.1 and CustomAttributes works fine
http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/


All code changes you can view in Show Log dialog of TortoiseSVN client for revision 4585

Why don't you want to post a sample reproduces the PartialViewResult issue?

Vladimir
Mar 18, 2013, 4:42 PM
The problem is that when you serialized the nodes to its Json string and bind it the the javascript side, the Custom Attributes are not being serialized.

Please demonstrate it in simple example

gets_gui
Mar 18, 2013, 5:24 PM
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>

Vladimir
Mar 18, 2013, 8:56 PM
Your sample works fine for me, i see data in columns
Tested with versions from
http://svn.ext.net/premium/branches/2 <- source code for Ext.Net 2.1.1
http://svn.ext.net/premium/branches/2.1
http://svn.ext.net/premium/trunk