EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: gordis gmbh on November 20, 2018, 11:37:35 PM



Title: Combobx issue: default item selection when itemValue = 0
Post by: gordis gmbh on November 20, 2018, 11:37:35 PM
Hello,

I have set up a combobox with static data. The first item, which has 0 as value, is automatically selected.

 
  •   Why is this element by default selected?
  • How can I avoid this behavior?


For more details please have a look at this example http://jsfiddle.net/2491fkha/
 
Thanks.


Title: Re: Combobx issue: default item selection when itemValue = 0
Post by: stworthy on November 21, 2018, 07:12:18 AM
Please set the 'value' with a non empty value such as -1, or try to put this code to the page to fix this issue.
Code:
<script>
$.extend($.easyui, {
indexOfArray: function(a, o, id){
for(var i=0,len=a.length; i<len; i++){
if (id == undefined){
if (a[i] == o){return i;}
} else {
if (String(a[i][o]) == String(id)){return i;}
}
}
return -1;
}

})
</script>