Originally Posted by
Daniil
Hi Daniil,
We have tried this (
http://mvc.ext.net/#/TreePanel_Loaders/Direct_Method/) and
error is same.
Here are the change according to 'http://mvc.ext.net/#/TreePanel_Loaders/Direct_Method/' in previous code.
Instead of code line
.Listeners(x => x.BeforeItemClick.Fn = "LoadNodes")
We changed it to
.Listeners(l => { l.BeforeLoad.Fn = "LoadNodes"; })
as per your suggestion.
Another change is code line
var node = App.TreeGridId.getStore().getNodeById(operation.data.id);
is replaced by code line
var node = operation.node;
But result is same,
we got same ext.net exception window.
We also tried this 'http://mvc.ext.net/#/TreePanel_Loaders/Proxy/', It simply does not support TreeGrid feature.
Adding below line of code in markup gives error of not support this TreeGrid feature.
.Fields(
Html.X().ModelField().Name("nodeText"),
Html.X().ModelField().Name("iconHtml").Type(ModelFieldType.String)
)
.ColumnModel(
Html.X().Column().Align(Alignment.Right).DataIndex("iconHtml").Renderer("displayIcons").Width(75),
Html.X().TreeColumn().DataIndex("nodeText").Width(280)
)
We need TreeGrid feature, because we want to display some icons on first column. This is our project requirement and with this feature now we want on demand loading as we have very large amount of Tree node data that can not be processed at start.
Here is modified code again in case you want to verify the changes as per your suggested link sample -
Controller Code (No change compared to previous)
[DirectController(GenerateProxyForOtherControllers = true, IDMode = DirectMethodProxyIDMode.None)]
public class ExtNetController : Controller
{
public ActionResult ProxyTree()
{
NodeCollection nodes = new NodeCollection();
Node node = new Node();
node.NodeID = "1000";
node.Text = "FirstNode";
for (int i = 0; i < 5; i++)
{
Node childnode = new Node();
childnode.NodeID = i.ToString();
childnode.Text = "Node " + i;
childnode.Expanded = false;
node.Children.Add(childnode);
childnode.AttributesObject = new { nodeText = "Node " + i, iconHtml = "<img src='iconImage.png' width='15' height='15' />" };
}
node.AttributesObject = new { nodeText = node.Text, iconHtml = "<img src='iconImage.png' width='15' height='15' />" };
nodes.Add(node);
return View(nodes);
}
[DirectMethod]
public ActionResult LoadChildNodes(string nodeId)
{
NodeCollection nodes = new Ext.Net.NodeCollection() {
new Node(){NodeID = Guid.NewGuid().ToString(), Text = "ChildNodeText1", AttributesObject = new {nodeText = "ChildNodeText1", iconHtml= "<img src='iconImage.png' width='15' height='15' />" }},
new Node(){NodeID = Guid.NewGuid().ToString(), Text = "ChildNodeText2", AttributesObject = new {nodeText = "ChildNodeText2", iconHtml= "<img src='iconImage.png' width='15' height='15' />" }},
new Node(){NodeID = Guid.NewGuid().ToString(), Text = "ChildNodeText3", AttributesObject = new {nodeText = "ChildNodeText3", iconHtml= "<img src='iconImage.png' width='15' height='15' />" }},
new Node(){NodeID = Guid.NewGuid().ToString(), Text = "ChildNodeText4", AttributesObject = new {nodeText = "ChildNodeText4", iconHtml= "<img src='iconImage.png' width='15' height='15' />" }}
};
if (nodeId == "1000")
{
return this.Direct(new Ext.Net.NodeCollection());
}
else
{
return this.Direct(nodes);
}
}
}
View code (change as explained above)
@model NodeCollection
<html>
<style>
.no-node-icon img.x-tree-icon
{
display: none;
}
</style>
<head>
<meta name="viewport" content="width=device-width" />
<title>ProxyTree</title>
<script type="text/javascript">
var displayIcons = function (value, meta, record, index) {
return Ext.String.format(record.data.iconHtml);
};
var LoadNodes = function (store, operation, options) {
var node = operation.node; // App.TreeGridId.getStore().getNodeById(operation.data.id);
App.direct.LoadChildNodes(node.getId(), {
success: function (result) {
if (result.length > 0) {
node.set('loading', false);
node.set('loaded', true);
node.removeAll();
node.appendChild(result);
}
},
eventMask: {
showMask: true,
minDelay: 500
},
failure: function (errorMsg) {
Ext.Msg.alert('Failure', errorMsg);
}
});
}
</script>
</head>
<body>
<div>
@Html.X().ResourceManager()
@(Html.X().Container().ID("TreeGrid").Height(400).Items(
Html.X().TreePanel().ID("TreeGridId").Header(false)
.RootVisible(false)
.HideHeaders(true)
.Icon(Icon.None)
.UseArrows(true)
.Cls("no-node-icon")
.Fields(
Html.X().ModelField().Name("nodeText"),
Html.X().ModelField().Name("iconHtml").Type(ModelFieldType.String)
)
.ColumnModel(
Html.X().Column().Align(Alignment.Right).DataIndex("iconHtml").Renderer("displayIcons").Width(75),
Html.X().TreeColumn().DataIndex("nodeText").Width(280)
)
.Root(Html.X().Node().NodeID("0").Text("All Notes").Children(Model))
//.Listeners(x => x.BeforeItemClick.Fn = "LoadNodes")
.Listeners(l => { l.BeforeLoad.Fn = "LoadNodes"; })
)
)
</div>
</body>
</html>
Could it not be possible to make change to ignore the exception window in existing code, as other things are working as expected. Only this exception window comes with sending unnecessary request to parent action method (in this case 'ProxyTree()', might be root cause of this) which is not required.
Waiting for your positive response to fix this.
Thanks