Aug 15, 2012, 6:09 PM
[CLOSED] ext:TreePanel - record.raw property is undefined to nodes in depth 1
Hi!!!
I'm working with ext:TreePanel in cliente side (javascript)...
I'm creating some properties in nodes when I'm building treePanel.
The properties that I created in node are represented in raw property of record of node.
But, for nodes of first level, below of root node, (depth 1), the raw property is undefined... All others nodes, in different levels, have your raw property filled.
What I do wrong?
I made a little sample.
I'm working with ext:TreePanel in cliente side (javascript)...
I'm creating some properties in nodes when I'm building treePanel.
The properties that I created in node are represented in raw property of record of node.
But, for nodes of first level, below of root node, (depth 1), the raw property is undefined... All others nodes, in different levels, have your raw property filled.
What I do wrong?
I made a little sample.
<%@ Page Language="vb" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
Ext.onReady(function () {
var contas = [{ ID: 'MailAccount1', Name: 'Mail Account 1', Default: 1 }, { ID: 'MailAccount2', Name: 'Mail Account 2', Default: 0}];
var viewPort = Ext.create("Ext.net.Viewport", {
id: "ViewportConsole",
renderTo: Ext.getBody(),
layout: 'border'
});
var paneMsg = viewPort.add({
id: 'paneMsg',
region: 'south',
height: 200,
html: 'click in tree node to list the record.raw property of node'
});
var tree = viewPort.add({
itemId: 'tvpContas',
xtype: 'treepanel',
enableDD: true,
containerScroll: true,
region: 'center',
border: false,
layout: 'fit',
autoScroll: true,
rootVisible: false,
useArrows: true,
root: {
children: {}
},
listeners: {
itemclick: {
fn: function (tree, record) {
var html = '';
var node = this.getView().getNode(record);
html += 'Node: ' + record.data.text;
html += '</br>Deph: ' + record.data.depth;
if (record.raw != undefined) {
for (prop in record.raw) {
html += '<br>' + prop + ': ' + record.raw[prop];
}
} else {
html += '</br></br>raw property of record is undefined';
}
paneMsg.body.update(html);
}
}
}
});
tree.getRootNode().removeAll();
var root = tree.getRootNode();
var nodes = [];
for (var i = 0; i < contas.length; i++) {
var folders = [];
var subFolders = [];
//carrego os nodos filhos
//recebidos
folders.push({
text: 'InBox',
itemId: contas[i].ID + '.Inbox',
iconCls: 'email_tree_recebidos_16',
leaf: true,
conta: contas[i],
idPasta: 0,
tipo: 1,
isSystemFolder: true
});
folders.push({
text: 'OutBox',
itemId: contas[i].ID + '.OutBox',
iconCls: 'email_tree_enviados_16',
leaf: true,
conta: contas[i],
idPasta: 0,
tipo: 2,
isSystemFolder: true
});
subFolders.push({
text: 'subfolder 1',
itemId: contas[i].ID + 'subfolder1',
leaf: false,
conta: contas[i],
idPasta: 1,
tipo: 1,
isSubFolder: true
});
subFolders.push({
text: 'subfolder 2',
itemId: contas[i].ID + 'subfolder2',
leaf: false,
conta: contas[i],
idPasta: 1,
tipo: 1,
isSubFolder: true
});
folders.push({
text: 'SubFolders',
itemId: contas[i].ID + '.SubFolders',
iconCls: 'email_tree_enviados_16',
children: subFolders,
leaf: false,
conta: contas[i],
idPasta: 1,
tipo: 0,
isFolder: true
});
nodes.push({
text: contas[i].Name,
itemId: "conta_" + contas[i].ID,
iconCls: 'email_tree_conta_16',
leaf: false,
conta: contas[i],
isConta: true,
children: folders,
expanded: contas[i].Default
});
}
root.appendChild(nodes);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
</form>
</body>
</html>
Last edited by Daniil; Aug 16, 2012 at 1:11 PM.
Reason: [CLOSED]