FineUI 官方论坛
标题:
关于DataView控件的问题,求三石兄帮忙
[打印本页]
作者:
Fatesy
时间:
2012-6-19 12:41
标题:
关于DataView控件的问题,求三石兄帮忙
本帖最后由 Fatesy 于 2012-6-19 12:52 编辑
DataView在有一些场合下非常必要,最近项目中需要实现类似的功能,extjs已经提供了,可惜extaspnet还没封装,只能尝试用extjs实现了,最后还是实现了。
本来想修改extaspnet的源码,直接把控件嵌进extaspnet内部.但是是由于对extaspnet的框架不是非常理解,花费了很多精力依然无果,只能求三石兄帮忙了。
[attach]699[/attach]
关键的代码如下
Ext.onReady(function () {
var myData = [
['dance_fever.jpg', 'images/dance_fever.jpg', 71.72, '9/1 12:00am'],
['gangster_zack.jpg', 'images/gangster_zack.jpg', 29.01, '9/1 12:00am'],
['kids_hug2.jpg', 'images/kids_hug2.jpg', 83.81, '9/1 12:00am'],
['kids_hug.jpg', 'images/kids_hug.jpg', 29.01, '9/1 12:00am'],
['sara_pink.jpg', 'images/sara_pink.jpg', 29.01, '9/1 12:00am'],
['sara_pumpkin.jpg', 'images/sara_pumpkin.jpg', 29.01, '9/1 12:00am'],
['sara_smile.jpg', 'images/sara_smile.jpg', 29.01, '9/1 12:00am'],
['up_to_something.jpg', 'images/up_to_something.jpg', 29.01, '9/1 12:00am'],
['zack.jpg', 'images/zack.jpg', 29.01, '9/1 12:00am'],
['zack_dress.jpg', 'images/zack_dress.jpg', 29.01, '9/1 12:00am'],
['zack_hat.jpg', 'images/zack_hat.jpg', 29.01, '9/1 12:00am'],
['zack_sink.jpg', 'images/zack_sink.jpg', 29.01, '9/1 12:00am'],
['zacks_grill.jpg', 'images/zacks_grill.jpg', 29.01, '9/1 12:00am']
];
var store = new Ext.data.SimpleStore({
fields: [
{ name: 'name' },
{ name: 'url' },
{ name: 'size', type: 'float' },
{ name: 'lastmod', type: 'date', dateFormat: 'n/j h:ia' }
]
});
store.loadData(myData);
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{name}">',
'<div class="thumb"><img src="{url}" title="{name}"></div>',
'<span >{shortName}</span></div>',
'</tpl>',
'<div class="x-clear"></div>'
);
var panel = new Ext.Panel({
id:'images-view',
frame:true,
width:215,
collapsible:true,
layout:'fit',
title:'Simple DataView (0 items selected)',
items: new Ext.DataView({
store: store,
tpl: tpl,
overClass: 'x-view-selected',
itemSelector:'div.thumb-wrap',
emptyText: 'No images to display',
prepareData: function(data){
data.shortName = Ext.util.Format.ellipsis(data.name, 15);
data.sizeString = Ext.util.Format.fileSize(data.size);
data.dateString = data.lastmod.format("m/d/Y g:i a");
return data;
},
listeners: {
click : {
fn : function( dataView, index, node, e) {
var record = dataView.getRecord(node);
alert(record.get("name"));
}
}
}
})
});
panel.render(document.body);
});
复制代码
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4