gpt4 book ai didi

extjs4.1 - 未捕获的类型错误 : Cannot read property 'internalId' of undefined( WHILE SORTING NODES ON EXPAND)

转载 作者:行者123 更新时间:2023-12-02 19:52:20 27 4
gpt4 key购买 nike

我想在展开时对树节点进行排序。我一直在努力使用以下代码在 extjs 4.1.0 中使用 itemexpandbeforeItemExpand 事件来执行此操作。它在 ExtJS 4.2.1 中运行良好。

当我单击节点展开时,我得到:

Uncaught TypeError: Cannot read property 'internalId' of undefined  at:  
ns[i].viewRecordId = records[i].internalId
in updateIndexes : function(startIndex, endIndex) method of Ext.view.AbstractView
class

代码:

var mystore = Ext.create('Ext.data.TreeStore', {
fields: ['displayName', 'type', 'value', 'stateSize', 'percentOfParent'],
root: {
"displayName": "state",
"name": "state",
"stateSize": 1.91,
"percentOfParent": 100.0,
"percentOfTotalstate": 100.0,
"leaf": false,
"cls": "highlight-new",
"children": [{
"displayName": "Component Tree",
"name": "Tree",
"stateSize": 0.25,
"percentOfParent": 13.0,
"percentOfstate": 13.0,
"leaf": true,
"cls": "highlight-new",
"iconCls": "task",
}, {
"displayName": "crap",
"name": "Tree",
"stateSize": 0.25,
"percentOfParent": 13.0,
"percentOfstate": 13.0,
"leaf": true,
"cls": "highlight-new",
"iconCls": "task",
}]
});

Ext.define('xyz.mytree', {
extend: 'Ext.tree.Panel',
title: 'State',
alias: 'widget.state',
width: 150,
height: 150,
columns: [{
xtype: 'treecolumn',
header: 'Name',
dataIndex: 'displayName',
width: 300
}, {
header: 'Type',
dataIndex: 'type',
width: 275
}, {
header: 'Value',
dataIndex: 'value',
align: 'left',
width: 275
}, {
header: 'Size (KB)',
dataIndex: 'stateSize',
align: 'right',
width: 95
}, {
header: '% Of Parent',
dataIndex: 'percentOfParent',
align: 'right',
width: 95
}],
store: mystore,

listeners: {

itemExpand: function (node) {
sortFunction = function (o1, o2) {
if (o1.data.displayName < o2.data.displayName) {
return -1;
} else if (o1.data.displayName > o2.data.displayName) {
return 1;
} else {
return 0;
}
};

if (!node.expanded) {
node.sort(sortFunction, false, false);
node.expanded = true;
}
}

},

constructor: function (config) {
this.callParent(arguments);
}

});

在 4.1 中,如果使用的事件是 itemExpand 或 beforeItemExpand,我会收到上述错误。但如果我使用 afterItemExpand 它工作正常。在 4.2.1 中,它在其他事件上也运行良好...

有什么想法为什么会发生这种情况吗?还有其他选择吗?如果问题不清楚,请告诉我谢谢

最佳答案

我在使用Ext.view.View时遇到了同样的问题

按照建议here我变了

itemSelector: 'div'

itemSelector: 'div#someId'

https://architectslog.wordpress.com/2013/05/13/sencha-ext-js-4-and-cannot-read-property-internalid-of-undefined/

关于extjs4.1 - 未捕获的类型错误 : Cannot read property 'internalId' of undefined( WHILE SORTING NODES ON EXPAND),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17558355/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com