您的位置:首页 > 其它

Sencha touch中Ext.List如何高度自适应的解决方法

2014-03-20 13:43 429 查看
在使用Sencha Touch2.0的List控件时我们都知道必须指定List的Height,否则将不会显示,而我们在使用List的时候往往是将其放在页面的一个版块,而不会是简单的

           fullscreen:true

此时我们为了让List能自适应高度,将Height指定为100%会其他比例,单却还是无法显示,具体原因当然很多,在下并不太会css,因此在此之前就是因为因为无法达到预期效果才想出下面这种笨拙的方法,勿喷:

Ext.define('app.view.MyList', {

    extend: 'Ext.List',

    xtype: 'commentList',

    config: {

        itemHeight: 60,

        scrollable: {

            disabled: true

        },

       store: 'MyStore'

   },

    refresh: function()

    {

        var height = this.getStore().getCount();

        if(height){

              this.setHeight(this.getItemHeight()* height);

        }   

        this.callParent(arguments);

    }

});

核心就是重载List的refresh方法,动态改变其高度。个人觉得这个方法必然效率太差,但还没想到更好的,欢迎大家慷慨解囊,提出更好方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sencha 控件