ext panel 自定义图片刷新

最近从管理回归开发,着实是花了些功夫适应,不过换个角度处理问题,貌似效果不错大笑,废话不多说,最近项目用到了EXT js,百度大神里面没找到一个合适的图片组件,自己写了个可以刷新的图片组件,先说明:由于项目原因,只能贴出部分代码,此代码仅供参考

思路:先删除,再添加,使用doLayout()重布局


防止读取缓存中图片: 在图片链接后面加上" '?' + Math.random()",会从后台重新读取


代码如下:

         imagePanel = new Ext.Panel(

                                {
                                    region : 'center',
                                    title : '',
                                    id : 'imagePanel',
                                    name : 'imagePanel',
                                    width : 105,
                                    height : 105,
                                    border : false,
                                    bodyStyle : {
                                        padding : '10px'
                                    },
                                    refresh : function(picName) {
                                        picName = picName + '?' + Math.random();
                                        imagePanel.removeAll();
                                        var imageInPanel = new Ext.Panel(
                                                {
                                                    region : 'center',
                                                    title : '',
                                                    id : 'imageInPanel',
                                                    name : 'imageInPanel',
                                                    border : false,
                                                    width : 95,
                                                    height : 95,
                                                    html : "<img src='"
                                                            + picName
                                                            + "' width='80px' height='80px' style='padding:5px;'></img>"
                                                });
                                        imagePanel.add(imageInPanel);
                                        imagePanel.doLayout();

                                    }

                                });


刷新图片:imageBrowsePanel.refresh(picName);

picName中包括图片相对路径,建议路径写在后台配置中,方便修改


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值