tobiu
28 Jan 2009, 2:18 AM
hi together,
this is a small extension to sakis fabolous LovCombo.
@saki: if you like this modifications of your extension, feel free to include them.
i will only post the added / modified parts of the original source:
Ext.ux.form.LovCombo.css:
.ux-lovcombo-image {
width:16px;
height:16px;
float:left;
background-position: -1px -1px ! important;
background-repeat:no-repeat ! important;
margin-left:2px;
margin-right:5px;
}
Ext.ux.form.LovCombo.js:
Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, {
// {{{
// configuration options
/**
* @cfg {String} checkField name of field used to store checked state.
* It is automatically added to existing fields.
* Change it only if it collides with your normal field.
*/
checkField:'checked'
/**
* @cfg {String} iamge-url to use between checkboxes and itemtexts
*/
,imageField:false
/**
* @cfg {String} separator separator to use between values and texts
*/
,separator:','
/**
* @cfg {String/Array} tpl Template for items.
* Change it only if you know what you are doing.
*/
// }}}
// {{{
,initComponent:function() {
// template with checkbox
if(!this.tpl) {
this.tpl =
'<tpl for=".">'
+'<div class="x-combo-list-item">'
+'<img src="' + Ext.BLANK_IMAGE_URL + '" '
+'class="ux-lovcombo-icon ux-lovcombo-icon-'
+'{[values.' + this.checkField + '?"checked":"unchecked"' + ']}">'
+'<tpl if="' + this.imageField +' != false">'
+'<img class="ux-lovcombo-image" src="../images/icons/{' + this.imageField + '}">'
+'</tpl>'
+'<div class="ux-lovcombo-item-text">{' + (this.displayField || 'text' )+ '}</div>'
+'</div>'
+'</tpl>'
;
}
// call parent
Ext.ux.form.LovCombo.superclass.initComponent.apply(this, arguments);
...
you can use the imageField-config to use a store field for image-urls.
if you dont use this config, the LovCombo looks like the original one.
if you use it, make sure all entries got an image-url (use blank-images if needed).
kind regards, tobiu
here a screenshot, how it looks:
this is a small extension to sakis fabolous LovCombo.
@saki: if you like this modifications of your extension, feel free to include them.
i will only post the added / modified parts of the original source:
Ext.ux.form.LovCombo.css:
.ux-lovcombo-image {
width:16px;
height:16px;
float:left;
background-position: -1px -1px ! important;
background-repeat:no-repeat ! important;
margin-left:2px;
margin-right:5px;
}
Ext.ux.form.LovCombo.js:
Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, {
// {{{
// configuration options
/**
* @cfg {String} checkField name of field used to store checked state.
* It is automatically added to existing fields.
* Change it only if it collides with your normal field.
*/
checkField:'checked'
/**
* @cfg {String} iamge-url to use between checkboxes and itemtexts
*/
,imageField:false
/**
* @cfg {String} separator separator to use between values and texts
*/
,separator:','
/**
* @cfg {String/Array} tpl Template for items.
* Change it only if you know what you are doing.
*/
// }}}
// {{{
,initComponent:function() {
// template with checkbox
if(!this.tpl) {
this.tpl =
'<tpl for=".">'
+'<div class="x-combo-list-item">'
+'<img src="' + Ext.BLANK_IMAGE_URL + '" '
+'class="ux-lovcombo-icon ux-lovcombo-icon-'
+'{[values.' + this.checkField + '?"checked":"unchecked"' + ']}">'
+'<tpl if="' + this.imageField +' != false">'
+'<img class="ux-lovcombo-image" src="../images/icons/{' + this.imageField + '}">'
+'</tpl>'
+'<div class="ux-lovcombo-item-text">{' + (this.displayField || 'text' )+ '}</div>'
+'</div>'
+'</tpl>'
;
}
// call parent
Ext.ux.form.LovCombo.superclass.initComponent.apply(this, arguments);
...
you can use the imageField-config to use a store field for image-urls.
if you dont use this config, the LovCombo looks like the original one.
if you use it, make sure all entries got an image-url (use blank-images if needed).
kind regards, tobiu
here a screenshot, how it looks: