EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on January 26, 2016, 12:48:22 AM



Title: Proxy Comboboxes
Post by: devnull on January 26, 2016, 12:48:22 AM
I have some pages where there are several comboboxes containing exactly the same data, easyu creates a hidden panel for each of these identical combos.

Is it possible to clone or proxy a single combo so that the items panel is only created once ?

I am desperatly tring to reduce the page size and this would really help ?


Title: Re: Proxy Comboboxes
Post by: jarry on January 27, 2016, 07:44:23 AM
Please try to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.4-patch.zip, call 'cloneFrom' method to clone the combobox components.
Code:
<input id="cc" class="easyui-combobox" ...>
<input id="c1">
<script type="text/javascript">
$(function(){
$('#c1').combobox('cloneFrom', '#cc');
})
</script>


Title: Re: Proxy Comboboxes
Post by: devnull on December 09, 2016, 03:22:09 AM
Hi Jarry;

Any suggestions on how I can extend eui so that I can use this inline like this:

Code:
<input id="test1" class="easyui-combobox" data-options="data:[{value:1,text:'one'},{value:2,text:'two'}]">
<input id="test2" class="easyui-combobox" data-options="cloneFrom:'#test1'">
<input id="test3" class="easyui-combobox" data-options="cloneFrom:'#test1'">
<input id="test4" class="easyui-combobox" data-options="cloneFrom:'#test1'">


EDIT
Code:
	$.extend($.fn.combobox.methods, {
cloneFrom: function(jq, from){
return jq.each(function(){
$(this).combo('cloneFrom', from);
$.data(this, 'combobox', $(from).data('combobox'));
$(this).addClass('combobox-f').attr('comboboxName', $(this).attr('textboxName'));
});
},

I just spotted a problem with cloneFrom() - if you select a value in a cloned combo, it selects a record in the source combo and not  itself ??


Title: Re: Proxy Comboboxes
Post by: jarry on December 09, 2016, 07:25:00 PM
Please download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.5-patch.zip
Code:
<input id="test1" class="easyui-combobox" data-options="data:[{value:1,text:'one'},{value:2,text:'two'}]">
<input id="test2">
<input id="test3">
<input id="test4">
<script type="text/javascript">
$(function(){
$('#test2,#test3,#test4').combobox('cloneFrom', '#test1');
})
</script>


Title: Re: Proxy Comboboxes
Post by: devnull on December 10, 2016, 05:55:52 PM
Thanks, but I am using 1.4.4 I cannot upgrade to 1.5 as it breaks a lot of my extensions and work-arounds.

I can't find the cloneFrom() function in that download, is it possble to let me have the updated cloneFrom extension ?

Many Thanks


Title: Re: Proxy Comboboxes
Post by: jarry on December 11, 2016, 05:51:43 AM
Please download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4.4-patch.zip.