效果图:

extjs代码:

// 模型
Ext.define('ParkingAttachment', {extend: "Ext.data.Model",
idProperty: 'id',
fields:[
{name:'id'},
{name:'parkingId'},
{name:'attachment'},
{name:'attachmentName'},
{name:'attachmentUrl'}
]
}); // 存储
var parkingAttachmentStore = Ext.create('Ext.data.Store', {
model: 'ParkingAttachment',
autoLoad: true,
proxy: {
type: 'ajax',
actionMethods: {
read: "POST"
},
url: securedroot + 'squadron/getParkingAttachment',
reader: {
type: 'json'
}
}
}); // 面板
var attachmentPanel = Ext.create('Ext.Panel', {
id: 'images-view',
iconCls: 'silk-attach',
autoScroll: true,
frame: true,
margin: '-5 20 5 10',
height: 300,
title: '图片预览',
items: Ext.create('Ext.view.View', {
store: parkingAttachmentStore,
margin: '5 20 5 20',
tpl: [
'<tpl for=".">',
'<div class="thumb-wrap x-view-item-focused" id="{attachmentName}" style="height: 230px; margin:10px 35px 10px 35px;cursor:pointer;>',
'<div class="thumb"><img style="max-height: 220px;max-width: 275px;vertical-align:middle;" src="' + ORCH_SYSCONTANT.FILE_VIEW_URI + '{attachmentUrl}" title="{attachmentName}"></div>',
'</div>',
'</tpl>',
'<div class="x-clear"></div>'
],
multiSelect: false,
trackOver: true,
itemSelector: 'div.thumb-wrap',
emptyText: '没有图片显示',
plugins: [
Ext.create('Ext.ux.DataView.DragSelector', {})
],
prepareData: function (data) {
Ext.apply(data, {
shortName: Ext.util.Format.ellipsis(data.attachmentName, 15),
});
return data;
},
listeners: {
itemclick: function (dv, nodes) {
var url = nodes.data.attachmentUrl;
window.open(ORCH_SYSCONTANT.FILE_VIEW_URI + url);
}
}
})
});

以下是上述代码中用到的变量:

// 国际化:
FILE_VIEW_URI: 'http://10.10.1.212:5980/sitefiles/lhzhzfpro/zf/file/'

// CSS样式
.thumb {
background-color: #ffffff;
border-radius: 3px;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
margin-top: 30px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
width: 100%;
} #images-view .thumb-wrap {
border: 2px solid #EAEAEE;
float: left;
margin-right:;
padding: 5px;
height: 120px;
}
.x-view-item-focused {
outline: 1px dashed #c0d4ed!important;
outline-offset: -1px;
}

ext图片预览功能实现,前端代码的更多相关文章

  1. 如何通过js实现图片预览功能

    一.效果预览 效果图: 二.实现代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  2. 原生JS实现图片预览功能

    html代码: <div class="album-new fr"> <div class="upload-btn btn-new container& ...

  3. 原生js实现ajax的文件异步提交功能、图片预览功能.实例

    采用html5使得选择图片改变时,预览框中图片随之改变.input文件选择框美化.原生js完成文件异步提交 效果图: 代码如下,可直接复制并保存为html文件打开查看效果 <html> & ...

  4. HTML5实现图片预览功能

    两种方式实现 URL FileReader Index.jsp文件 <%@page contentType="text/html" pageEncoding="UT ...

  5. H5图片预览功能

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  6. JavaScript图片上传前的图片预览功能

    JS代码: //js本地图片预览,兼容ie[6-9].火狐.Chrome17+.Opera11+.Maxthon3 function PreviewImage(fileObj, imgPreviewI ...

  7. 34)django-上传文件,图片预览功能实现

    目录 文件上传      1)form表单提交上传(会刷新)      2)ajax上传      3)iframe      4)图片上传预览(思路保存文件的时候,把文件保存文件的路径反馈回,客户端 ...

  8. 自定义type为file型input控件+该控件具有本地图片预览功能

    最近的一个项目需求是写一个type为filex型的input控件,这个控件: 第一,要自定义样式: 第二,要能直接在本地预览上传的图片: 第三,要能检测图片的尺寸是否符合要求. 故综合网上的资源写了下 ...

  9. html页面选择图片上传时实现图片预览功能

    实现效果如下图所示 只需要将下面的html部分的代码放入你的代码即可 (注意引入jQuery文件和html头部的css样式,使用的是ajax提交) <!-- 需引入jQuery 引入样式文件 引 ...

随机推荐

  1. [Swift]LeetCode985. 查询后的偶数和 | Sum of Even Numbers After Queries

    We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i] ...

  2. [Swift]LeetCode997. 找到小镇的法官 | Find the Town Judge

    In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people is se ...

  3. 【jpa】spring data jpa 配置使用

    1.spring data jpa 简单介绍 jpa是用于对象持久化的API,jpa是一种规范,而其他的ORM框架(hibernate,topLink等)是其实现,所以jpa可以使用不同的实现方式,修 ...

  4. Jason Wang: 结对编程 CountWord(第三次作业)

    本次作业地址: https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/homework/2882 学号: 201731072323 ...

  5. BBS论坛(五)

    5.1.cms后台修改密码功能完成 (1)新建app/forms.py # app/forms.py from wtforms import Form class BaseForm(Form): de ...

  6. Socket.io发送消息含义

    仅作收藏:转自博客园 若相忆; // send to current request socket client socket.emit('message', "this is a test ...

  7. 【转】ret,retf,iret的区别

    ret RET, and its exact synonym RETN, pop IP or EIP from the stack and transfer control to the new ad ...

  8. java基础(五)-----关键字static

    在Java中并不存在全局变量的概念,但是我们可以通过static来实现一个“伪全局”的概念,在Java中static表示“全局”或者“静态”的意思,用来修饰成员变量和成员方法,当然也可以修饰代码块. ...

  9. Kafka基础简介

    kafka是一个分布式的,可分区的,可备份的日志提交服务,它使用独特的设计实现了一个消息系统的功能. 由于最近项目升级,需要将spring的事件机制转变为消息机制,针对后期考虑,选择了kafka作为消 ...

  10. Chapter 4 Invitations——26

    "I wanted to ask you something, but you sidetracked me," he chuckled. He seemed to have re ...