sencha自定义ImageField用于表单中显示图片

苦于sencha源码中,

xtype            Class
---------------------------------------
textfield        Ext.field.Text
numberfield      Ext.field.Number
textareafield    Ext.field.TextArea
hiddenfield      Ext.field.Hidden
radiofield       Ext.field.Radio
filefield        Ext.field.File
checkboxfield    Ext.field.Checkbox
selectfield      Ext.field.Select
togglefield      Ext.field.Toggle
fieldset         Ext.form.FieldSet
并没有imagefield,显示图片起来非常麻烦,于是查看源码自定义了一个ImageField


secnha-touch-defineBySelf,js该文件在secha原库和程序入口之间加载即可

<script src="js/sencha-touch-all-2.3.0.js"></script>
<script src="js/sencha-touch-defineBySelf.js"></script>
<script src="app.js"></script>

secnha-touch-defineBySelf,js内容如下:

/** 
 * @Class Ext.Img.ImageField
 * @createTime 2014-04-03
 * 用于表单中的ImageField,通过setValue()来设置图片路径显示图片,通过getValue()来获得图片的路径
 * 	form.getValues()时也会在values中存入图片的相应路径字段
 * 		用法:
 * 			具有一般的Panel的所有属性,并且还多一个一个value属性可以设置图片的路径
 */
Ext.define('Ext.field.ImageField', {
	extend : 'Ext.Panel',
	xtype : ['imagefield', 'imgfield'],
	
    isField: true,
    isFormField: true,
	
	config : {
		name : null,
		value : null,
		items: [
        {
			xtype : 'img',
			id : 'self-img_photo',
			width : '100%',
			height : '100%',
			margin : '0 0 0 0',
			style : '{background-repeat:no-repeat; background-size:100% auto; background-position:center;}',
		},
		],
	},
	
	setValue : function(path) {
		Ext.getCmp('self-img_photo').setSrc(path);
	},
	
	getValue : function() {
		return Ext.getCmp('self-img_photo').getSrc();
	},
	
});



版权所有,转载请注明出处!http://blog.csdn.net/kuailebeihun_/article/details/22900591




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值