EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on July 13, 2022, 08:09:15 AM



Title: Change combobox option with javascript
Post by: rezzonico on July 13, 2022, 08:09:15 AM
Hi all,

I have a combobox with "editable: false".
I want to change this options to "true" with a javascript.

Here is the code but it doesn't works.

http://62.48.115.40/jeasyui

Thanks for any help
Miche


Title: Re: Change combobox option with javascript
Post by: jarry on July 14, 2022, 08:17:14 AM
Please call the 'setEditable' method to change the 'editable' mode. Make sure to update to the newest version.

Code:
$('#Plant').combobox('setEditable', false);
$('#Plant').combobox('setEditable', true);


Title: Re: Change combobox option with javascript
Post by: rezzonico on July 15, 2022, 12:44:17 AM
Thanks !

The problem is that I have an "old" release.
Is it possible to use a command like this ?

$('#Plant').combobox('textbox').attr('editable', true);

Regards
Miche


Title: Re: Change combobox option with javascript
Post by: jarry on July 15, 2022, 09:13:03 PM
This is the extended method to set the editable feature.
Code:
<script type="text/javascript">
$.extend($.fn.validatebox.methods, {
setEditable: function(jq, mode){
jq.each(function(){
var opts = $.data(this, 'validatebox').options;
opts.editable = mode==undefined ? true : mode;
$(this).validatebox('readonly', opts.readonly);
})
}
})
$.extend($.fn.textbox.methods, {
setEditable: function(jq, mode){
jq.each(function(){
var state = $.data(this, 'textbox');
var opts = state.options;
var tb = state.textbox;
var input = tb.find('.textbox-text');
opts.editable = mode==undefined ? true : mode;
input.validatebox('setEditable', opts.editable);
$(this).textbox('readonly', opts.readonly);
})
}
})
</script>

Now you can call the 'setEditable' method in your 'old' code.
Code:
$('#Plant').combobox('setEditable', false);
$('#Plant').combobox('setEditable', true);


Title: Re: Change combobox option with javascript
Post by: rezzonico on July 20, 2022, 04:50:10 AM
Thanks !

Regards
Miche