下拉框可选择多列图片

4 篇文章 0 订阅
2 篇文章 0 订阅
前台extjs

Ext.ns('Ext.ux');
Ext.ux.CssShowCombo = Ext.extend(Ext.form.ComboBox ,{
array : [],
selectOnFocus : true,
minListWidth : 200,
pageSize : 50,
autoScroll : true,
lazyInit : true,
typeAhead : true,
triggerAction : 'all',
lazyRender : true,
mode : 'remote',
valueField : 'name',
displayField : 'name',
initComponent : function(){
Ext.ux.CssShowCombo.superclass.initComponent.call(this);
},
store: new Ext.data.Store({
url : contextPath+'/cssShow/getData.do',
reader : new Ext.data.JsonReader({
root: 'root',
totalProperty: 'totalCount',
fields: [
{name: 'name'},
{name: 'url'}
]
})
}),
tpl : new Ext.XTemplate(
'<table>',
'<tr>',
'<tpl for=".">',
'<td class="x-combo-list-item" height="16px" width="16px">',
'<img src="{url}" />',
'</td>',
'<tpl if="xindex % 5 === 0">',//if="xindex % 5 === 0"
'</tr>',
'<tr>',
'</tpl>',
'</tpl>',
'</tr>',
'</table>'
),
/*onRender:function(ct,position) {
// call parent onRender
Ext.ux.CssShowCombo.superclass.onRender.call(this, ct, position);

// adjust styles
this.wrap.applyStyles({position:'relative'});
this.el.addClass('ux-icon-combo-input');

// add div for icon
this.icon = Ext.DomHelper.append(this.el.up('div.x-form-field-wrap'), {
tag: 'img', style:'position:absolute;height:16px;width:16px;left:0px;'
});
},

setIconCls: function(value) {
var rec = this.store.query(this.valueField, this.getValue()).itemAt(0);
if(rec) {
this.icon.src = rec.get('url');
}
},

setValue: function(value) {
Ext.ux.CssShowCombo.superclass.setValue.call(this, value);
this.setIconCls(value);
},*/
listeners : {
'beforerender' : function(thisCmp){
if(this.array.length<=0){
//若要引入其他css,在数组urls配置对应url即可
var urls=[
'/resources/css/silk.css'
];
var content = '';
var i = 1;
var silkSuccFn = function(response,opts){
var text = response.responseText;
content += text;
if(i<urls.length){
/*Gov.Ajax.request({
url:contextPath+urls[i],
mskCfg:{el:this.el},
success:silkSuccFn,
scope:this
});*/
Ext.Ajax.request({
url:contextPath+urls[i],
success:silkSuccFn,
scope:this
});
}else if(i==urls.length){
/*Gov.Ajax.request({
url : contextPath+'/cssShow/dealCssContent.do',
mskCfg : {el:this.el},
params : {'content':content},
success : function(response,opts){
var ary = response.responseText;
var obj = Ext.decode(ary);
var lines = obj.lines;
for(var i=0;i < lines.length;i++){
this.array.push(lines[i]);
}
var param = {"array" : this.array};
thisCmp.getStore().baseParams = param;
},
scope : this
});*/
Ext.Ajax.request({//兼容性问题,使用Gov.Ajax.request 无法在ie中发送请求
url : contextPath+'/cssShow/dealCssContent.do',
params : {'content':content},
success : function(response,opts){
var ary = response.responseText;
var obj = Ext.decode(ary);
var lines = obj.lines;
for(var i=0;i < lines.length;i++){
this.array.push(lines[i]);
}
var param = {"array" : this.array};
thisCmp.getStore().baseParams = param;
},
scope : this
});
}
i++;
}
Gov.Ajax.request({
url : contextPath+urls[0],
mskCfg : {el:this.el},
success : silkSuccFn,
scope : this
});
}
},
'expand' : function(thisCmp){//水平滚动条
this.innerList.dom.style.overflowX="auto";
}

}
});
Ext.reg('cssshowcombo',Ext.ux.CssShowCombo);

看不懂可call me
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值