首页 > 其他 > 详细

ext panel 自定义图片刷新

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

最近从管理回归开发,着实是花了些功夫适应,不过换个角度处理问题,貌似效果不错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 自定义图片刷新

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!