未被捕获的TypeError:无法读取未定义的属性"internalId"(在扩展时进行点排序) [英] Uncaught TypeError: Cannot read property 'internalId' of undefined( WHILE SORTING NODES ON EXPAND)

查看:218
本文介绍了未被捕获的TypeError:无法读取未定义的属性"internalId"(在扩展时进行点排序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对展开的树节点进行排序.我一直在努力使用itemexpandbeforeItemExpand事件在extjs 4.1.0中使用以下代码进行此操作.在ExtJS 4.2.1中可以正常工作.

I want to the sort the tree node when it is expanded. I have been struggling to do this in extjs 4.1.0 with itemexpand or beforeItemExpand event using the following code. It works fine in ExtJS 4.2.1.

当我单击节点以展开时,得到以下信息:

When I click on node to expand, I get this:

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中,它在其他事件上也能正常工作...

In 4.1, if the event used is itemExpand or beforeItemExpand, I receive the above error. But if I use afterItemExpand it works fine. in 4.2.1 it works fine on other events as well...

有什么想法为什么会这样?有没有其他选择?让我知道是否有一些不清楚的问题 谢谢

Any ideas why this is happening? Is there any alternative? Let me know if something is not clear abt the problem Thanks

推荐答案

我在使用Ext.view.View

因此,如建议此处 我改变了

So as suggested here I changed

itemSelector: 'div'

itemSelector: 'div#someId'

查看全文

相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆