View Full Version : [Workaround] Image in Combobox options?
cluettr
7 Jul 2007, 1:17 PM
Is it possible to place an image/icon next to each option within the combobox? I looked through the threads and I didn't find any.
Skeleton
8 Jul 2007, 4:06 AM
I have done a similar thing at work for a project. I couldn't see any built-in funcionality for this in the Ext library but it is a pretty simple thing and can be done wrting a few CSS rules. I will try to put the code I have used here if I don't forget tomorrow while I was at office (bump this thread or better PM me tomorrow)
Skeleton
8 Jul 2007, 11:19 PM
This is the rule that I have used for icons in combo:
.x-combo-list-item {
background: url(/WebtopLite/img/ico-library.gif) no-repeat 1px 2px;
padding-left: 20px;
}
Here how it looks like:
897
cluettr
9 Jul 2007, 5:44 AM
Thank you Skeleton. I think this would only allow you to apply one image for all options, correct?
liggett78
9 Jul 2007, 5:54 AM
Thank you Skeleton. I think this would only allow you to apply one image for all options, correct?
That's true as long as you use this CSS class for all items. Another option is to use (maybe not yet documented) tpl config option. Combobox is a templated control, so you can customize the appearance of items in the list as you like it.
Ext.form.ComboBox({
...
tpl : '<div><img ... /></div>',
...
});
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.