Extjs实现类似windows中资源管理器方式的图标文件清单
2011-12-28 21:06
369 查看
在Extjs中对文件或数据清单列表显示,最常见就是采用GRID方式来显示数据,笔者在使用中,发现可以采用图标方式显示文件清单(注:需要使用到插件Ext.ux.grid.ExplorerView这个插件)。以下是文件的现实界面,通过扩充功能,完全能达类似资源管理器的效果。
实际使用插件中发现,不能自动换行,只好自己定义CSS了
实际使用插件中发现,不能自动换行,只好自己定义CSS了
CSS代码: .icon-grid { background-image:url(../shared/icons/fam/grid.png) !important; } .thumb-wrap{ float: left; margin: 4px; margin-right: 0; padding: 0px; width: 250px; height: 60px; border: 1px solid #EDEDED; } .x-view-over{ border:1px solid #dddddd; background: #efefef url(../js/extjs/resources/images/default/grid/row-over.gif) repeat-x left top; padding: 0px; } .x-view-selected{ background: #efefef url(../js/extjs/resources/images/default/grid/row-over.gif) repeat-x left top; border:1px solid #99bbe8; padding: 0px; } .x-vgrid3-cell-inner{ overflow:hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; padding:3px 3px 3px 5px; white-space: nowrap; } .x-vgrid3-cell-inner{ width: 200px; } 显示模板代码: }); var tpl=new Ext.XTemplate( '<tpl for=".">', '<div class="thumb-wrap {alt}" id="{fileid}">', '<table class="x-grid3-row-table"><tbody>', '<tr>', '<td class="x-grid3-col x-grid3-cell ux-explorerview-icon"><img src="images/{fileimg}" width="48" height="48"></td>', '<td ><div class="x-vgrid3-cell-inner" unselectable="on">{FileNum}<br>{FileRname}<br><span>{fileunit}<br>{filedate}<br></span></div></td>', '</tr>', '</tbody></table></div>', '</tpl>', '<div class="x-clear"></div>' ); 为方便阅读者在图标列表和清单列表方式切换显示,采用DataView和GridPanel ,通过layout:'card'布局来实现 部分代码: var Filedataview=new Ext.DataView( { name:'Filedataview', store:ds, tpl:tpl, loadMask: { msg:"数据加载中(Data 첨가)...." }, singleSelect:true, selectedClass:"x-view-selected", overClass:'x-view-over', itemSelector:'div.thumb-wrap', autoDestroy:true, prepareData:function (data) { data.filesize=Ext.util.Format.fileSize(data.filesize); return data; }, listeners: { 'dblclick':function (t,n,node,e) { alert(n); } } }); var FileViewgrid=new Ext.Panel( { animCollapse:false, frame:false, border:false, autoDestroy:true, items:[Filedataview] }); var FileListgrid=new Ext.grid.GridPanel( { ds:ds, cm:cm, stripeRows:true, loadMask: { msg:"数据加载中(Data 첨가)...." }, ViewConfig: { forceFit:true }, autoScroll:true, frame:false, border:false, autoDestroy:true, animCollapse:false }); var viewtabpanel=new Ext.Panel( { name:'viewtabpanel', enableTabScroll:true, layout:'card', activeItem:0, margins:'0 5 0 0', frame:false, border:false, autoDestroy:true, items:[FileViewgrid,FileListgrid] } ); var viewpanel=new Ext.Panel( { margins:'0 5 0 0', layout:'fit', autoDestroy:true, frame:false, border:false, width:Ext.get("Filemanagerdiv").getWidth(), height:Ext.get("Filemanagerdiv").getHeight(), renderTo:'Filemanagerdiv', bbar:new Ext.PagingToolbar( { pageSize:limit, store:ds, displayInfo:true, emptyMsg:"没有登记文件", plugins:new Ext.ux.Andrie.pPageSize(), displayMsg:'显示第 {0} 条到 {1} 条文件,一共 {2} 个文件' }), tbar:new Ext.Toolbar( { autoDestroy:true, items:[ { xtype:'tbseparator' }, { xtype:'button', iconCls:'icon_view', tooltip:'以图表方式查看文件', handler:function () { viewtabpanel.layout.setActiveItem(0); showview=0; } }, { xtype:'tbseparator' }, { xtype:'button', iconCls:'icon_list', tooltip:'以列表清单方式查看文件', handler:function () { viewtabpanel.layout.setActiveItem(1); showview=1; } }, { xtype:'tbseparator' }, { xtype:'button', text:"新增", iconCls:'icon_add', handler:Addfiles }, { xtype:'tbseparator' }, { xtype:'button', text:"查看文件", tooltip:'查看文件', iconCls:'icon_Pages', handler:ViewCheckFile }, { xtype:'tbseparator' }, { xtype:'button', text:"编辑", iconCls:'icon_edit', handler:EditViewCheckFile }, { xtype:'tbseparator' }, { xtype:'button', text:"删除", iconCls:'icon_delete', tooltip:'从服务器将该文件删除', handler:DelUploadCheckFiles }, { xtype:'tbseparator' }, { xtype:'tbsplit', text:"查询数据", iconCls:'icon_search', handler:function () { }, menu: { items:[ { text:'所有数据', iconCls:'icon_list', handler:_clearsearch }, { text:'按条件查询', iconCls:'icon_list', handler:_addsearch } ] } }, { xtype:'tbfill' }, { xtype:'button', text:"排序", iconCls:"icon_delete" }, { xtype:'tbseparator' }, { xtype:'button', text:"统计", iconCls:"icon_piechart" }, { xtype:'tbseparator' } ] }), items:viewtabpanel } ); ds.load( { params: { start:start, limit:limit } }); DataView和GridPanel共用一个Ds和PagingToolbar。
相关文章推荐
- Java类中获取文件的方式以及实现一个类似js中的eval函数
- ANDROID使用MULTIPARTENTITYBUILDER实现类似FORM表单提交方式的文件上传
- HttpClient 4.3.6 使用MultipartEntityBuilder实现类似form表单提交方式的文件上传
- ASP.NET 2.0实现类似QQ邮箱中‘HTML方式查看’功能查看Office文件
- 用js文件创建一个带参数的view client的快捷方式(类似的bat形式也可模仿实现),并实现自动登录
- Android使用MultipartEntityBuilder实现类似form表单提交方式的文件上传
- XP中完美实现vista中快捷方式右键添加“打开文件位置”功能
- [转帖]通过文件读写方式实现Matlab和Modelsim的联合仿真
- 采用多线程的方式实现文件下载
- openFileOutput 文件属性设置、主动配置文件的可读写属性及其实现方式
- EXTJS学习系列提高篇:第十三篇(转载)作者殷良胜,利用Ext实现Icon小图标的部分用法
- golang 实现文件拷贝的2种方式
- springMVC两种方式实现多文件上传及效率比较
- ExtJs 实现类似QQ的提示消息框
- C/C++语言之通过定义指针函数方式来实现在一个cpp文件里面获取另外一个cpp文件函数的返回值
- 用递归的方式实现文件内容搜索(java)
- android Widget 桌面小图标,类似快捷方式
- java 实现文件复制的两种方式
- 用JSP实现类似资源管理器式的文件与目录的折叠(代码示例)
- 浅谈文件捆绑技术及实现方式