ExtJs 3.x 以编程方式滚动 ListView

发布于 2024-11-10 07:58:18 字数 2813 浏览 1 评论 0原文

下面的代码直接来自 3.x 示例。

谁能帮助我编写移动列表视图主体的脚本,就像它正在滚动一样?

谢谢, 乔什

Ext.onReady(function(){
    var store = new Ext.data.JsonStore({
        fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}],
        data : [{"name":"dance_fever.jpg","size":2067,"lastmod":1265631056000,"url":"images\/thumbs\/dance_fever.jpg"}
                ,{"name":"gangster_zack.jpg","size":2115,"lastmod":1265631056000,"url":"images\/thumbs\/gangster_zack.jpg"}
                ,{"name":"kids_hug.jpg","size":2477,"lastmod":1265631056000,"url":"images\/thumbs\/kids_hug.jpg"}
                ,{"name":"kids_hug2.jpg","size":2476,"lastmod":1265631056000,"url":"images\/thumbs\/kids_hug2.jpg"}
                ,{"name":"sara_pink.jpg","size":2154,"lastmod":1265631056000,"url":"images\/thumbs\/sara_pink.jpg"}
                ,{"name":"sara_pumpkin.jpg","size":2588,"lastmod":1265631056000,"url":"images\/thumbs\/sara_pumpkin.jpg"}
                ,{"name":"sara_smile.jpg","size":2410,"lastmod":1265631056000,"url":"images\/thumbs\/sara_smile.jpg"}
                ,{"name":"up_to_something.jpg","size":2120,"lastmod":1265631056000,"url":"images\/thumbs\/up_to_something.jpg"}
                ,{"name":"zack.jpg","size":2901,"lastmod":1265631056000,"url":"images\/thumbs\/zack.jpg"}
                ,{"name":"zacks_grill.jpg","size":2825,"lastmod":1265631056000,"url":"images\/thumbs\/zacks_grill.jpg"}
                ,{"name":"zack_dress.jpg","size":2645,"lastmod":1265631056000,"url":"images\/thumbs\/zack_dress.jpg"}
                ,{"name":"zack_hat.jpg","size":2323,"lastmod":1265631056000,"url":"images\/thumbs\/zack_hat.jpg"}
                ,{"name":"zack_sink.jpg","size":2303,"lastmod":1265631056000,"url":"images\/thumbs\/zack_sink.jpg"}]
    });

    var listView = new Ext.list.ListView({
        id      : 'listview',
        store: store,
        multiSelect: true,
        emptyText: 'No images to display',
        columns: [{
            header: 'File',
            width: .45,
            dataIndex: 'name'
        },{
            header: 'Last Modified',
            xtype: 'datecolumn',
            format: 'm-d h:i a',
            width: .3, 
            dataIndex: 'lastmod'
        },{
            header: 'Size',
            dataIndex: 'size',
            tpl: '{size:fileSize}',
            align: 'right',
            cls: 'listview-filesize'
        }]
    });

    // put it in a Panel so it looks pretty
    var panel = new Ext.Panel({
        id:'images-view',
        width:425,
        height:250,
        collapsible:true,
        resizable : true,
        layout:'fit',
        title:'Simple ListView <i>(0 items selected)</i>',
        items: listView
    });
    panel.render(document.body);
});

The code below is straight out of the 3.x examples.

Can anyone help me with the script that moves the listview body, as if it was being scrolled?

Thanks,
Josh

Ext.onReady(function(){
    var store = new Ext.data.JsonStore({
        fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}],
        data : [{"name":"dance_fever.jpg","size":2067,"lastmod":1265631056000,"url":"images\/thumbs\/dance_fever.jpg"}
                ,{"name":"gangster_zack.jpg","size":2115,"lastmod":1265631056000,"url":"images\/thumbs\/gangster_zack.jpg"}
                ,{"name":"kids_hug.jpg","size":2477,"lastmod":1265631056000,"url":"images\/thumbs\/kids_hug.jpg"}
                ,{"name":"kids_hug2.jpg","size":2476,"lastmod":1265631056000,"url":"images\/thumbs\/kids_hug2.jpg"}
                ,{"name":"sara_pink.jpg","size":2154,"lastmod":1265631056000,"url":"images\/thumbs\/sara_pink.jpg"}
                ,{"name":"sara_pumpkin.jpg","size":2588,"lastmod":1265631056000,"url":"images\/thumbs\/sara_pumpkin.jpg"}
                ,{"name":"sara_smile.jpg","size":2410,"lastmod":1265631056000,"url":"images\/thumbs\/sara_smile.jpg"}
                ,{"name":"up_to_something.jpg","size":2120,"lastmod":1265631056000,"url":"images\/thumbs\/up_to_something.jpg"}
                ,{"name":"zack.jpg","size":2901,"lastmod":1265631056000,"url":"images\/thumbs\/zack.jpg"}
                ,{"name":"zacks_grill.jpg","size":2825,"lastmod":1265631056000,"url":"images\/thumbs\/zacks_grill.jpg"}
                ,{"name":"zack_dress.jpg","size":2645,"lastmod":1265631056000,"url":"images\/thumbs\/zack_dress.jpg"}
                ,{"name":"zack_hat.jpg","size":2323,"lastmod":1265631056000,"url":"images\/thumbs\/zack_hat.jpg"}
                ,{"name":"zack_sink.jpg","size":2303,"lastmod":1265631056000,"url":"images\/thumbs\/zack_sink.jpg"}]
    });

    var listView = new Ext.list.ListView({
        id      : 'listview',
        store: store,
        multiSelect: true,
        emptyText: 'No images to display',
        columns: [{
            header: 'File',
            width: .45,
            dataIndex: 'name'
        },{
            header: 'Last Modified',
            xtype: 'datecolumn',
            format: 'm-d h:i a',
            width: .3, 
            dataIndex: 'lastmod'
        },{
            header: 'Size',
            dataIndex: 'size',
            tpl: '{size:fileSize}',
            align: 'right',
            cls: 'listview-filesize'
        }]
    });

    // put it in a Panel so it looks pretty
    var panel = new Ext.Panel({
        id:'images-view',
        width:425,
        height:250,
        collapsible:true,
        resizable : true,
        layout:'fit',
        title:'Simple ListView <i>(0 items selected)</i>',
        items: listView
    });
    panel.render(document.body);
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒儿 2024-11-17 07:58:18

下面的代码假设您希望将 listView 向下滚动 50 像素。

var listView = Ext.get('listView'); 
var listViewBody = listView.el.child('.x-list-body'); 
listViewBody.scroll('down', 50);

The code below assumes you would like to scroll the listView down by 50pixels.

var listView = Ext.get('listView'); 
var listViewBody = listView.el.child('.x-list-body'); 
listViewBody.scroll('down', 50);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文