1

我有以下代码在树商店内创建一个可扩展的树面板。我的问题是autoscrolltrue 和 scroll tr​​ue 我已经有了一个滚动条。

当我在树中展开一个文件夹时,会创建一个 gridscroll 并将其附加到主容器中,并并排创建两个滚动条。

如何捕获扩展文件夹并防止呈现网格滚动条?

我认为这是setAutoScroll(false)列上的方法,但我不知道如何设置它。

Ext.Loader.setConfig({
    enabled: true,
    disableCaching: false
});
Ext.require(['Ext.form.*', 'Ext.tree.*', 'Ext.grid.*', 'Ext.data.*', 'Ext.util.*', 'Ext.tip.QuickTipManager', 'Ext.ux.grid.FiltersFeature', 'Ext.ModelManager']);

Ext.onReady(function() {
    Ext.define('model1', {
        extend: 'Ext.data.Model',
        fields: [{
            name: 'text',
            type: 'string'
        }, {
            name: 'pathInfo',
            type: 'string'
        }]
    });

    storeAddTo = Ext.create('Ext.data.TreeStore', {
        model: 'model1',
        folderSort: true,
        root: {
            expanded: true,
            children: myJSONTextAddTo
        }
    });

    var treeConfigAddTo = {

        //title: 'Select an existing folder from the list',
        id: 'grid-foldersAddTo',
        width: 320,
        height: 330,
        store: storeAddTo, //
        rootVisible: false,
        useArrows: true,
        singleExpand: false,
        renderTo: 'grid-foldersAddTo',
        columns: [{
            xtype: 'treecolumn',
            text: 'Folders',
            flex: 1,
            sortable: false,
            dataIndex: 'text',
            filterable: false
        }],
        viewConfig: {
            autoScroll: true,
            scroll: true,
        }
    }

    treeAddTo = Ext.create('Ext.tree.Panel', treeConfigAddTo);

});

数据(myJSONTextAddTo)

[{
    text: "Cars",
    "pathInfo": "Cars",
    children: [{
        text: "Luxury",
        "pathInfo": "Cars\\Luxury\\Bentley",
        children: [{
            text: "Bentley",
            "pathInfo": "Cars\\Luxury\\Bentley",
            children: []
        }, {
            text: "Porsche",
            "pathInfo": "Cars\\Luxury\\Porsche",
            children: [{
                text: "Cars",
                "pathInfo": "Cars\\Luxury\\Porsche\\Cars\\Luxury\\Porsche",
                children: [{
                    text: "Luxury",
                    "pathInfo": "Cars\\Luxury\\Porsche\\Cars\\Luxury\\Porsche",
                    children: [{
                        text: "Porsche",
                        "pathInfo": "Cars\\Luxury\\Porsche\\Cars\\Luxury\\Porsche",
                        children: []
                    }]
                }]
            }]
        }]
    }, {
        text: "Dealers",
        "pathInfo": "Cars\\Dealers",
        children: []
    }, {
        text: "Ferrari",
        "pathInfo": "Cars\\Ferrari",
        children: []
    }, {
        text: "Sports",
        "pathInfo": "Cars\\Sports",
        children: [{
            text: "Chevy",
            "pathInfo": "Cars\\Sports\\Chevy",
            children: []
        }]
    }, {
        text: "mycar",
        "pathInfo": "Cars\\mycar",
        children: []
    }, {
        text: "test2",
        "pathInfo": "Cars\\test2",
        children: []
    }, {
        text: "test3",
        "pathInfo": "Cars\\test3",
        children: []
    }, {
        text: "test4",
        "pathInfo": "Cars\\test4",
        children: []
    }, {
        text: "test5",
        "pathInfo": "Cars\\test5",
        children: []
    }, {
        text: "test 6",
        "pathInfo": "Cars\\test 6",
        children: [{
            text: "Test 6.1",
            "pathInfo": "Cars\\test 6\\Test 6.1",
            children: []
        }]
    }]
}]
4

1 回答 1

2

看看这个小提琴: http: //jsfiddle.net/dbrin/Qc5XV/ 我删除了您拥有的视图配置并删除了高度约束以允许树生长。我希望这就是你所追求的。如果您想修复高度,请取消注释高度配置,树面板将在需要时自动滚动。这对我来说似乎是正确的。如果是这样,您可能在树周围有其他面板给您带来问题,请让我知道布局,我们可以进一步排除故障。希望这可以帮助。

于 2012-08-27T04:18:57.793 回答