EasyUI Forum
May 17, 2024, 08:59:42 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: prepend a blank option to combobox  (Read 8539 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: May 27, 2014, 11:00:58 PM »

How can I add a blank entry to the top of the combobox list ?

I have tried these without success:

Code:
  onLoadSuccess: function(data){
    return data.push({"txt":"","val":""});
    $(this).prepend("<option value=''></option>").val('');
  }

  onLoadSuccess: function(data){
    $(this).prepend("<option value=''></option>").val('');
  }

« Last Edit: May 28, 2014, 12:39:00 AM by devnull » Logged

-- Licensed User --
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: May 28, 2014, 01:13:30 AM »

You can use 'loadFilter' function to prepend an empty row, please try this code:
Code:
$('#cc').combobox({
  loadFilter:function(data){
       var opts = $(this).combobox('options');
       var emptyRow = {};
       emptyRow[opts.valueField] = '';
       emptyRow[opts.textField] = '&nbsp;';
       data.unshift(emptyRow);
       return data;
  }
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!