|
devnull
|
 |
« on: December 07, 2015, 06:39:30 PM » |
|
I have added a icon to the combo records which works just fine, but how can I show the icon when the record is selected ? $('#xxx').combobox({ panelHeight:'auto', data:[ {text:'My Documents',value:'n',selected:true,iconCls:'folder_user'}, {text:'All Documents',value:'y',iconCls:'folder_share'} ], formatter: function(row){ return '<span style="background: url(../icons/'+row.iconCls+'.png) no-repeat left center;padding-left:22px;">'+row.text+'</span>' }, })
|
|
|
|
« Last Edit: January 11, 2016, 04:23:49 AM by devnull »
|
Logged
|
-- Licensed User --
|
|
|
|
devnull
|
 |
« Reply #1 on: December 07, 2015, 08:16:19 PM » |
|
Hi; I have managed to get it to work using the onSelect event, but how can I do this without using up the onSelect event as I would like to make it a global feature that can be applied to any combobox ? $('#xxx').combobox({ panelHeight:'auto', data:[ {text:'My Documents',value:'n',selected:true,iconCls:'folder_user'}, {text:'All Documents',value:'y',iconCls:'folder_share'} ], formatter: function(rec){ return '<span style="background: url(../icons/'+rec.iconCls+'.png) no-repeat left center;padding-left:22px;">'+rec.text+'</span>' }, onSelect:function(rec){ $(this).combobox('textbox').css({'padding-left':'26px','background':'url(../icons/'+rec.iconCls+'.png) no-repeat 4px 2px'}); }, onResize: function(){ var me = $(this); setTimeout(function(){ var rec = me.combobox('getRec'); if(rec && rec.iconCls) me.combobox('textbox').css({'padding-left':'24px','background':'url(../icons/'+rec.iconCls+'.png) no-repeat 4px 3px','background-size':'14px'}); }); } })
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
stworthy
|
 |
« Reply #2 on: December 08, 2015, 11:54:30 PM » |
|
You can override the $.fn.combobox.defaults to make all combobox components get this feature. <style> .tb-icon{ display: inline-block; width: 16px; height: 16px; vertical-align: middle; } .textbox .tb-hasicon{ background-position: 4px center; padding-left: 20px; } </style> <script type="text/javascript"> $.extend($.fn.combobox.defaults, { formatter: function(row){ return '<span class="tb-icon '+row.iconCls+'"></span>'+row.text; }, onSelect: function(row){ var tb = $(this).combobox('textbox'); tb.attr('class', 'textbox-text validatebox-text'); if (row.iconCls){ tb.addClass(row.iconCls + ' tb-hasicon'); } } }); </script>
$('#cc').combobox({ data:[ {text:'My Documents',value:'n',selected:true,iconCls:'icon-save'}, {text:'All Documents',value:'y',iconCls:'icon-cut'} ] })
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #3 on: December 09, 2015, 02:24:12 AM » |
|
Thanks, but that's not really what I am after, as if I do that then the onSelect event will not be available to do other more important things.
Is there a way of achieving this WITHOUT using the onselect() event and preferably not using the formatter() as well ?
I am looking to add this as a global configurable option whilst still allowing the combobox to perform normally.
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
stworthy
|
 |
« Reply #4 on: December 13, 2015, 06:28:19 PM » |
|
The 'showItemIcon' property will be added to support this feature. $('#cc').combobox({ showItemIcon: true, data:[ {text:'My Documents',value:'n',selected:true,iconCls:'icon-save'}, {text:'All Documents',value:'y',iconCls:'icon-cut'} ] })
Make sure to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.4-patch.zip.
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #5 on: December 13, 2015, 10:44:54 PM » |
|
That's great, I was not expecting it to be integrated as a standard feature, thanks so much.
Will this plugin also work in 1.4.1 ?
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|
stworthy
|
 |
« Reply #6 on: December 13, 2015, 11:45:29 PM » |
|
This patch only works for version 1.4.4
|
|
|
|
|
Logged
|
|
|
|
|
devnull
|
 |
« Reply #7 on: December 19, 2015, 02:12:50 AM » |
|
Understood, thanks so much
|
|
|
|
|
Logged
|
-- Licensed User --
|
|
|
|