3
var tree = Ext.create('Ext.tree.Panel', {
        store: store,
        rootVisible: false,
        //useArrows: true,
        frame: true,
        title: 'Vehicle List',
        region:'west',
        width: 200,
        root: {
        expanded: true
        },
        checked : false,
        height: 250,
        dockedItems: [{
            xtype: 'toolbar',
            items: {
                text: 'Get checked nodes',
                handler: function(){
                    var records = tree.getView().getChecked(),
                        names = [];

                    Ext.Array.each(records, function(rec){
                        names.push(rec.get('MainID'));
                    });

                    Ext.MessageBox.show({
                        title: 'Selected Nodes',
                        msg: names.join('<br />'),
                        icon: Ext.MessageBox.INFO
                    });
                }
            }
        }]
    });

我怎样才能让树扩大?我试过了

root: {
        expanded: true
        }

但它仍然不起作用。

4

2 回答 2

4

将此添加到您的模型中:

{ name: 'expanded', type: 'boolean', defaultValue: true, persist: false },

或者expanded,为从服务器返回的每个节点设置为 true。

于 2013-02-28T18:09:36.243 回答
0
root: {
        expanded: true
      }

这应该在您商店的定义范围内。

像下面这样的东西。

var store = Ext.create('Ext.data.TreeStore', {
    root: {
        expanded: true,
        children: [
            { text: "a", leaf: true },
            { text: "b", expanded: true, children: [
                { text: "c", leaf: true },
                { text: "d", leaf: true}
            ] }
        ]
    }
});
于 2013-02-28T18:16:55.317 回答