May 07, 2014, 8:16 PM
Error: can't expand a TreePanel with two levels nodes
I have two problems with a tree node.I used a tree panel to display a 2-level tree of privileges with check boxes at the leaf nodes .
the first problem: when I expanded the first node it is expanded fine but when i expanded the second node it wasn't. without any javascript error
the second problem: when I expand the first node and click on check box of leaf node it didn't checked but the following checkbox is checked.
after more clicks on check boxes, javascript error raised
onCheckChange: function(record) {
var checked = record.get('checked');
if (Ext.isBoolean(checked)) {
checked = !checked;
record.set('checked', checked);
this.fireEvent('checkchange', record, checked);
}
}
I used the ext.net v2.5.1 downloaded from ext,net site because I faced [property 'isCollapsedPlaceholder' of undefined or null reference] proplem that solved in this thread http://forums.ext.net/showthread.php...null-reference
View Page:
the first problem: when I expanded the first node it is expanded fine but when i expanded the second node it wasn't. without any javascript error
the second problem: when I expand the first node and click on check box of leaf node it didn't checked but the following checkbox is checked.
after more clicks on check boxes, javascript error raised
Unhandled exception at line 1476, column 46 in http://XXX/extnet/extnet-all-js/ext.axd?v=31282
JavaScript runtime error: Unable to get property 'get' of undefined or null reference
with debuging i found record is null in this methodonCheckChange: function(record) {
var checked = record.get('checked');
if (Ext.isBoolean(checked)) {
checked = !checked;
record.set('checked', checked);
this.fireEvent('checkchange', record, checked);
}
}
I used the ext.net v2.5.1 downloaded from ext,net site because I faced [property 'isCollapsedPlaceholder' of undefined or null reference] proplem that solved in this thread http://forums.ext.net/showthread.php...null-reference
View Page:
@model Ext.Net.Node
@{
ViewBag.Title = "Group privileges";
}
@(Html.X().ResourceManager().ScriptMode(Ext.Net.ScriptMode.Development))
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<div class="back-link">
@Html.ActionLink("Back to List", "Index", null, new { @class = "pull-right" })
</div>
</div>
<div style="padding-top: 30px;">
@( Html.X().TreePanel().ID("TreePanel").Border(false)
.DisplayField("text") //Kp_Naziv
.Height(400).Width(500).UseArrows(false).Border(false).AutoScroll(true).Animate(true).RootVisible(false)
.Root(Model)
)
</div>
<div class="form-horizontal">
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
@Html.ActionLink("Back to Groups", "Index", null, new { @class = "btn btn-default" })
<input type="submit" value="Save" class="btn btn-default" onclick="return Save()" />
</div>
</div>
</div>
}
CS code: Action public ActionResult Privileges(int id)
{
ViewBag.GroupID = id;
Ext.Net.Node rootNode = new Node { NodeID = "0", Text = "Root", Checked = false, Icon = Icon.Folder, Leaf = false,Expanded=true};
var lists = db.Lists.ToList();
var groupColumn = db.GroupListItems.Where(o => o.GroupID == id);
foreach (var list in lists)
{
Ext.Net.Node node = new Node { NodeID = list.ListID.ToString(), Text = list.ListName, Icon = Icon.Table, Leaf = false,Expanded=false };
var columns = list.ListItems;
foreach (var column in columns)
{
node.Children.Add(new Node { NodeID = column.ListItemID.ToString(), Text = column.ItemID, Icon = Icon.TableColumn, Leaf = true, Checked = groupColumn.Any(o => o.ListItemID == column.ListItemID) });
}
rootNode.Children.Add(node);
}
return View("Privileges", rootNode);
}
Last edited by Daniil; May 09, 2014 at 1:59 PM.
Reason: cann't => can't