码迷,mamicode.com
首页 > 其他好文 > 详细

ext panel 自定义图片刷新

时间:2014-08-04 14:30:27      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   使用   io   问题   cti   ar   

最近从管理回归开发,着实是花了些功夫适应,不过换个角度处理问题,貌似效果不错bubuko.com,布布扣,废话不多说,最近项目用到了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中包括图片相对路径,建议路径写在后台配置中,方便修改


ext panel 自定义图片刷新,布布扣,bubuko.com

ext panel 自定义图片刷新

标签:style   blog   http   使用   io   问题   cti   ar   

原文地址:http://blog.csdn.net/xulei_19850322/article/details/38366251

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!