Hi everyone,
The url above returns one level nested data like this:
{users: [{"id": "user1", "text": "User1", "cls": "file"}, {"id": "users1", "text": "Users1", "cls": "folder"}]}
Cannot read property 'internalId' of undefined
I have a problem with Ext JS 4.1 Tree panel. I use a tree with a static store and attach a dynamically loaded node with it's store to initial tree as a child.
Here is the working example (I've found this example in the net and customized for my application):
Code:
Ext.define('demo.UserModel', {
extend: 'Ext.data.Model',
fields: ['text', 'cls']
});
var userTreeStore = Ext.create('Ext.data.TreeStore', {
model: 'demo.UserModel',
proxy: {
type: 'ajax',
url : '/users.php',
reader: {
type: 'json',
root: 'users'
},
pageParam: undefined,
startParam: undefined,
limitParam: undefined,
listeners: {
append: function() {
// custom icon processing goes here based on 'cls' property
}
}
}
});
userTreeStore.setRootNode({
text: 'Users',
id: 'users',
leaf: false,
expanded: false
});
var settingsTreeStore = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{
text: 'Settings',
leaf: false,
expanded: true,
children: [
{
text: 'System Settings',
leaf: true
},
{
text: 'Appearance',
leaf: true
},
{
text: 'Appearance',
leaf: true
},
{
text: 'Appearance',
leaf: true
},
{
text: 'Appearance',
leaf: true
}]
}]
}
});
settingsTreeStore.getRootNode().getChildAt(0).insertChild(2, userTreeStore.getRootNode()).expand();
Ext.onReady(function() {
Ext.create('Ext.tree.Panel', {
title: 'Panel',
renderTo: Ext.getBody(),
height: 300,
width: 300,
store: settingsTreeStore,
rootVisible: false,
listeners: {
itemclick: function(view, row, node, index, e) {
if(row.get('text') === 'Users') {
userTreeStore.load();
}
},
afterrender: function(tree) {
tree.getSelectionModel().select(tree.getStore().getRootNode().firstChild);
}
}
});
});
The url above returns one level nested data like this:
{users: [{"id": "user1", "text": "User1", "cls": "file"}, {"id": "users1", "text": "Users1", "cls": "folder"}]}
When I run this example and expand/collapse the dynamic Users node several times, I get the following js error:
TypeError: Cannot read property 'internalId' of undefined.
ext-all-debug.js updateIndexes method of Ext.view.AbstractView.
I don't have any duplicates in my data, it is correct. I have reviewed previous posts regarding this error but no fix was available.
Could you please look at this issue and provide a quick fix if it is possible?
Thanks in advance.
Cannot read property 'internalId' of undefined
Aucun commentaire:
Enregistrer un commentaire