效果图:

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]LeetCode271. 加码解码字符串 $ Encode and Decode Strings

    Design an algorithm to encode a list of strings to a string. The encoded string is then sent over th ...

  2. [Swift]LeetCode433. 最小基因变化 | Minimum Genetic Mutation

    A gene string can be represented by an 8-character long string, with choices from "A", &qu ...

  3. [Swift]LeetCode453. 最小移动次数使数组元素相等 | Minimum Moves to Equal Array Elements

    Given a non-empty integer array of size n, find the minimum number of moves required to make all arr ...

  4. [Swift]LeetCode605. 种花问题 | Can Place Flowers

    Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, ...

  5. [Swift]LeetCode900. RLE 迭代器 | RLE Iterator

    Write an iterator that iterates through a run-length encoded sequence. The iterator is initialized b ...

  6. [Swift]LeetCode906. 超级回文数 | Super Palindromes

    Let's say a positive integer is a superpalindrome if it is a palindrome, and it is also the square o ...

  7. Jedis与Luttuce区别

    如果你在网上搜索Redis 的Java客户端,你会发现,大多数文献介绍的都是 Jedis. 不可否认,Jedis是一个优秀的基于Java语言的Redis客户端. 但是,其不足也很明显:Jedis在实现 ...

  8. C# 当中 LINQ 的常规用法(Lambda 方式)

    仅以本篇博文记录 LINQ 相关操作的基本知识,原型参考自 MSDN 相关知识,中间加以自己的理解与 DEMO. 1. IEnuemrable<T>.Select() Select 方法比 ...

  9. 【学习】在Windows10平台使用Docker ToolBox安装docker(一)

    前言:今天距离元旦还有44天,时间点是18:11:45,想了想一路学习的过程和其中遇到的困难,其中有克服的,有放弃的,这有可能是我自己意志不坚定吧,学习docker也是我当下的一个目标,不知道会是成功 ...

  10. 在Mac上使用vs-code快速上手c语言学习(入门文,老鸟退散)

    天下事,合久必分.分久必合,你肯定想不到当你逃离到Mac平台这么多年之后,有一天你会再用微软的产品来写代码 :) 其实微软的产品虽然用户体验总是做不到最好,但整体上的确拉低了行业的进入门槛,对于编程也 ...