EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: tofix on September 12, 2016, 04:44:00 AM



Title: Datagrid FilterRow defaults combobox for 0
Post by: tofix on September 12, 2016, 04:44:00 AM
Hi,

however the combobox uses a data entry with value 0 (as number) as default.
How this can be disabled?

http://jsfiddle.net/xxxe1p79/

With line 31 with 0 as string the combo text of status filter will stay empty by default:
data:[{value:"0",text:'All'},{value:'P',text:'P'},{value:'N',text:'N'}],

With line 31 with 0 as number, the combo shows "All" as default:
data:[{value:0,text:'All'},{value:'P',text:'P'},{value:'N',text:'N'}],

How can I set data with a value of 0 as number while having the combo text empty as default without defining the number as string?

Thanks!


Title: Re: Datagrid FilterRow defaults combobox for 0
Post by: jarry on September 12, 2016, 06:56:50 AM
You can define a 'loadFilter' function to convert the 0 value to '0' string.
Code:
loadFilter:function(data){
    return $.map(data, function(item){
        if (item.value == 0){
            item.value = '0';
        }
        return item;
    })
}

Or clear the inputing box when loaded data successfully.
Code:
onLoadSuccess:function(){
    $(this).combobox('setText', '')
}


Title: Re: Datagrid FilterRow defaults combobox for 0
Post by: tofix on September 13, 2016, 05:38:13 AM
Thanks jarry, because setText will kepp the item selected, i will use the first version.