EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: 2plus2 on November 11, 2015, 03:23:26 PM



Title: Pass Empty Array to ComboBox?
Post by: 2plus2 on November 11, 2015, 03:23:26 PM
When the remote call returns an empty array "[]" to the combobox, should the combobox clear existing options or should there be no change?

e.g.
Code:
$('#billingYear').combobox('reload', '/controls/ajax.aspx?a=getYears&Customer_Id=' + x + '&Serial=' + y);

This call can return "nothing" as a valid response, e.g. "[]". I would expect the combobox to clear all existing values. Instead it stays unchanged.

using version 1.4.3


Title: Re: Pass Empty Array to ComboBox?
Post by: arma on November 11, 2015, 04:21:14 PM
You can clear the combobox before reloading.
$('#billingYear').combobox('loadData',[]);


Title: Re: Pass Empty Array to ComboBox?
Post by: 2plus2 on November 12, 2015, 08:18:26 AM
Thanks.

I'm currently checking the loaded data and using the clear option as a workaround. But I would think that on receiving a blank array the combobox would clear itself.

Code:
       onLoadSuccess: function (combo) {
            if (combo.length == 0) {
                $('#billingYear').combobox('clear');
            }
       },

I'll have to test and see if this behavior is consistent on older versions of jEasy.